09 2022 档案

摘要:// 二分查找 [left, right] // 数组已经是有序的了! public static int binarySerach1(int[] nums, int target) { if (nums == null || nums.length == 0) { return -1; } int 阅读全文
posted @ 2022-09-05 22:48 wjxuriel 阅读(42) 评论(0) 推荐(0)
摘要:我来解释一下,为什么要写成mid=left+(right-left)/2,而不是mid=(left+right)/2。 因为会溢出!!此时的溢出指的是,mid可能会超出该数据类型的最大值 我们假定一个数据类型 uint8 //数据范围0~255 uint8 left,right,mid; //假定 阅读全文
posted @ 2022-09-05 21:59 wjxuriel 阅读(375) 评论(0) 推荐(0)