我在java中工作,并且被限制在本机数组中,因此在我向数组中添加和值之前,必须设置数组的大小。我知道我无法找到sum列表的确切大小,因为如果两个元素相同,则不会将sum相加,但我正在尝试大致估计,这样我就不会有大量的数组。list length of original numbers * list length of original numbers) / 2 我试图记住时间复杂性,所以对有多少个和进行连续计数,将一个数组设置为这个大小
ind mid = (start + end )/2; // might be possible that the ( start+ end ) exceeds the range of int in java}else{ }
return -1;}
如果我们想在java中的二进制搜索中获得数组的末尾,那么编写int end = arr.length - 1的需要是什么,为什么不是