4-1 set的使用 Intersection of Two Arrays

查找有无:比如: ‘a’ 是否存在? 用set(相当于只有key)

查找对应关系:比如: ‘a’出现了几次? 用map(key-value 对应)

讲解:349. Intersection of Two Arrays

Given two arrays, write a function to compute their intersection.

Example: Given nums1=[1, 2, 2, 1],nums2=[2, 2], return[2].

4-2 map的使用 Intersection of Two Arrays II

讲解:

set 和 map 是容器类,这个类像一个容器一样用来存储我们的数据

results matching ""

    No results matching ""