1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
class : def fairCandySwap(self, A: List[int], B: List[int]) -> List[int]: flag = (sum(A) - sum(B)) // 2 for i in A: for j in B: if (i - j == flag): return [i, j]
class : def fairCandySwap(self, A: List[int], B: List[int]) -> List[int]: flag = (sum(A) - sum(B)) // 2 for i in A: if ((i-flag) in B): return [i, i-flag]
class : def fairCandySwap(self, A: List[int], B: List[int]) -> List[int]: dB = {k:True for k in B} totalA = sum(A) totalB = sum(B) for i in A: matching = totalB - totalA + 2*i if int(matching/2) in dB: return [i, int(matching/2)]
|
近期评论