五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

Leetcode 704 Binary Search

2021-12-25 15:10 作者:您是打尖兒還是住店呢  | 我要投稿

Given an array of integers?nums?which is sorted in ascending order, and an integer?target, write a function to search?target?in?nums. If?target?exists, then return its index. Otherwise, return?-1.

You must write an algorithm with?O(log n)?runtime complexity.

?

Example 1:

Input: nums = [-1,0,3,5,9,12], target = 9Output: 4Explanation: 9 exists in nums and its index is 4

Example 2:

Input: nums = [-1,0,3,5,9,12], target = 2Output: -1Explanation: 2 does not exist in nums so return -1

?

Constraints:

  • 1 <= nums.length <= 104

  • -104?< nums[i], target < 104

  • All the integers in?nums?are?unique.

  • nums?is sorted in ascending order.

典型的二分法:


Leetcode 704 Binary Search的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
和硕县| 齐河县| 华亭县| 上饶市| 长治县| 肇庆市| 德保县| 壤塘县| 康平县| 山东省| 开封市| 平邑县| 三亚市| 东安县| 阳信县| 泰安市| 平度市| 阿合奇县| 且末县| 永定县| 建平县| 屏边| 通江县| 龙岩市| 河北区| 布拖县| 章丘市| 沙坪坝区| 南汇区| 兰坪| 襄垣县| 东至县| 温州市| 成安县| 海口市| 诏安县| 安乡县| 大渡口区| 来凤县| 景东| 靖西县|