第 286 场周赛

阅读 44

2022-03-30

第 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 个硬币的最大面值和

精彩评论(0)

0 0 举报