二分查找(基础)

📅 2026/7/23 19:51:04
二分查找(基础)
思路准备一组有序的数组设置target设置i0 j 数组.length - 1;循环ij设置中间值m (m (ij)/2 ,向下取整)做ifa[m] target- j m-1 else if (a[m] target) - im1 else 返回m(索引)循环失败返回 -1代码截图:测试