leetcode888】的更多相关文章

Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, and B[j] is the size of the j-th bar of candy that Bob has. Since they are friends, they would like to exchange one candy bar each so that aft…
class Solution { public: int Binary_Search(vector<int> x, int N, int keyword) { , high = N - , mid; while (low <= high) { mid = (low + high) / ; if (x[mid] == keyword) return mid; if (x[mid] < keyword) low = mid + ; else high = mid - ; } ; } v…
爱丽丝和鲍勃有不同大小的糖果棒:A[i] 是爱丽丝拥有的第 i 块糖的大小,B[j] 是鲍勃拥有的第 j 块糖的大小. 因为他们是朋友,所以他们想交换一个糖果棒,这样交换后,他们都有相同的糖果总量.(一个人拥有的糖果总量是他们拥有的糖果棒大小的总和.) 返回一个整数数组 ans,其中 ans[0] 是爱丽丝必须交换的糖果棒的大小,ans[1] 是 Bob 必须交换的糖果棒的大小. 如果有多个答案,你可以返回其中任何一个.保证答案存在. 示例 1: 输入:A = [1,1], B = [2,2]…