888. Fair Candy Swap@python】的更多相关文章

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…
problem 888. Fair Candy Swap solution: class Solution { public: vector<int> fairCandySwap(vector<int>& A, vector<int>& B) { , sumB = , delta = ; unordered_set<int> setA; for(auto a:A) { sumA += a; setA.insert(a);//err... }…
作者: 负雪明烛 id: fuxuemingzhu 个人公众号: 每日算法题 本文关键词:力扣,LeetCode,算法题,算法,Python 目录 题目描述 题目大意 解题方法 代码 刷题心得 关于作者 日期 题目地址:https://leetcode.com/problems/fair-candy-swap/description/ 题目描述 Alice and Bob have candy bars of different sizes: A[i] is the size of the i-…
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…
题目要求 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 tha…
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…
题目: 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…
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…
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…
这是悦乐书的第339次更新,第363篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第208题(顺位题号是888).Alice和Bob有不同大小的糖果棒:A[i]是Alice拥有的第i个糖果棒的大小,B[j]是Bob拥有的第j个糖果棒的大小. 由于他们是朋友,他们想交换一个糖果,以便交换后,他们都有相同的糖果总量. (一个人拥有的糖果总量是他们拥有的糖果大小的总和.) 返回一个整数数组ans,其中ans[0]是Alice必须交换的糖果的大小,ans[1]是Bob必须交…