0
点赞
收藏
分享

微信扫一扫

第 286 场周赛

勇敢乌龟 2022-03-30 阅读 43

第 286 场周赛

第 286 场周赛

5268. 找出两数组的不同

class Solution:
    def findDifference(self, nums1: List[int], nums2: List[int]) -> List[List[int]]:
        a, b = set(nums1), set(nums2)
        return [list(a - b), list(b - a)]
class Solution {
    public List<List<Integer>> findDifference(int[] nums1, int[] nums2) {
        Set<Integer> a = new HashSet();        
        Set<Integer> b = new HashSet();
        for (int x : nums1) a.add(x);
        for (int x : nums2){ if (!a.contains(x)) b.add(x);}
        for (int x : nums2) {if (!b.contains(x)) a.remove(x);}
        return List.of(new ArrayList(a), new ArrayList(b));
    }
}

5236. 美化数组的最少删除数

5253. 找到指定长度的回文数

5269. 从栈中取出 K 个硬币的最大面值和

举报

相关推荐

力扣 第 286 场周赛

第 291 场周赛

leetcode 周赛 286

第 279 场周赛

第287场周赛

第 276 场周赛

[Acwing] 第 49 场周赛

LeetCode第290场周赛

0 条评论