Python 刷Leetcode题库,顺带学英语单词(8)

简介: Python 刷Leetcode题库,顺带学英语单词(8)

Find First and Last Position of Element in Sorted


Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.  [#34]

Your algorithm's runtime complexity must be in the order of O(log n).

If the target is not found in the array, return [-1, -1] .


   Example 1:

   Input: nums = [5,7,7,8,8,10], target = 8

   Output: [3,4]


   Example 2:

   Input: nums = [5,7,7,8,8,10], target = 6

   Output: [-1,-1]



Search Insert Position


Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.

You may assume no duplicates in the array.  [#35]


 

Example:
    Input: [1,3,5,6], 5
    Output: 2
    Input: [1,3,5,6], 2
    Output: 1
    Input: [1,3,5,6], 7
    Output: 4
    Input: [1,3,5,6], 0
    Output: 0



相关单词


position

英 [pəˈzɪʃn]   美 [pəˈzɪʃn]  

       n.位置;地方;恰当位置;正确位置;(坐、立的)姿态,姿势;放置方式

       vt.安装;安置;使处于

   词根-posit- 放,放置

   后缀-ion 表名词


ascend

英 [əˈsend]   美 [əˈsend]

v.上升;升高;登高

   前缀a- 加强

   词根-scend- 爬,攀


insert

英 [ɪnˈsɜːt , ˈɪnsɜːt]   美 [ɪnˈsɜːrt , ˈɪnsɜːrt]  

       vt.插入;嵌入;(在文章中)添加,加插

       n.(书报的)插页,广告附加页;插入物;添加物

   前缀in- 进入

   词根-sert- 加入








目录
相关文章
|
5天前
|
存储 索引 Python
leetcode-350:两个数组的交集 II(python中Counter的用法,海象运算符:=)
leetcode-350:两个数组的交集 II(python中Counter的用法,海象运算符:=)
31 0
|
6月前
|
测试技术
LeetCode字符串题库 之 罗马数字转整数
LeetCode字符串题库 之 罗马数字转整数
LeetCode字符串题库 之 罗马数字转整数
|
5天前
|
API Python
[AIGC] 使用Python刷LeetCode:常用API及技巧指南
[AIGC] 使用Python刷LeetCode:常用API及技巧指南
|
5天前
|
存储 JSON 数据可视化
Python期末复习题库(下)——“Python”
Python期末复习题库(下)——“Python”
|
5天前
|
数据采集 IDE 开发工具
Python期末复习题库(上)——“Python”
Python期末复习题库(上)——“Python”
|
5天前
|
算法 索引 Python
leetcode-138:复制带随机指针的链表 (python中copy与deepcopy区别)
leetcode-138:复制带随机指针的链表 (python中copy与deepcopy区别)
38 0
|
10月前
|
存储 算法 C++
(C语言版)力扣(LeetCode)题库1-5题解析
给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。
|
5天前
|
开发者 索引 Python
【python刷题】LeetCode 2057E 值相等的最小索引(5种简单高效的解法)
【python刷题】LeetCode 2057E 值相等的最小索引(5种简单高效的解法)
28 0
|
10月前
【Leetcode】题库-爽刷简单题(1)
【Leetcode】题库-爽刷简单题(1)
64 0
|
10月前
|
JSON 数据格式 Python
python解析考试题库数据
应单位要求需要参加某个考试,但考试需要从手机端登陆学习,1000多道题需要挨个刷一遍太过于麻烦,萌生了把题目和答案全部扒下来的想法,再用python做数据的清洗和梳理,最后整合出来所有的考试题库信息。
128 0