二分查找
数组-二分查找
我是真不会写代码啊
python是工作,java是生活。
展开
-
5. 367 有效的完全平方数(easy)
题目:367 有效的完全平方数(easy)一、题目二、 思路二、自己写的1.代码三、标准答案1.方法一(左闭右闭)2.方法二(完全平方数肯定是前n个连续奇数的和)3.方法三(牛顿迭代法)4.总结一、题目Given a positive integer num, write a function which returns True if num is a perfect square else False.Follow up: Do not use any built-in library func原创 2022-04-14 14:26:05 · 231 阅读 · 0 评论 -
4. 69 x的平方根(easy)
@[TOC](题目:69 Sqrt(x)(easy))一、题目Given a non-negative integer x, compute and return the square root of x.Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned.Note: You are not allowe原创 2022-04-13 16:40:56 · 72 阅读 · 0 评论 -
3. 34 在排序数组中查找元素的第一个和最后一个位置(mid)
题目:XXX一、题目二、 思路二、自己写的1.代码三、标准答案1.方法一(左闭右闭)2.方法二(左闭右开)3.总结题目:XXX一、题目二、 思路二、自己写的1.代码三、标准答案1.方法一(左闭右闭)2.方法二(左闭右开)3.总结Binary Search)一、题目Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search tar原创 2022-04-12 14:14:18 · 106 阅读 · 0 评论 -
1. 704 二分查找(easy)
题目:704 Binary Search(类别二分查找)一、题目二、 思路二、自己写的1.代码三、标准答案一、题目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.原创 2022-04-06 15:04:48 · 735 阅读 · 0 评论 -
2. 35 搜索插入位置(easy)
题目:35 搜索插入位置(二分查找)一、题目二、 思路二、自己写的1.代码三、标准答案1.方法一(左闭右闭)2.方法二(左闭右开)3.总结一、题目Given a sorted array of distinct integers 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原创 2022-04-06 19:33:24 · 936 阅读 · 0 评论