vault backup: 2022-06-28 09:07:47
This commit is contained in:
parent
b2560e3807
commit
07b823fb2d
|
@ -1,6 +1,7 @@
|
||||||
# Leetcode Intersection-of-Two-Arrays-II
|
# Leetcode Intersection-of-Two-Arrays-II
|
||||||
|
|
||||||
#### 2022-06-11
|
#### 2022-06-11
|
||||||
|
##### First revision 2022-06-27
|
||||||
|
|
||||||
---
|
---
|
||||||
##### Data structures:
|
##### Data structures:
|
||||||
|
@ -61,6 +62,9 @@ Given two integer arrays `nums1` and `nums2`, return _an array of their intersec
|
||||||
|
|
||||||
For the original problem, I thought up an O(m + n) algo, that uses C++'s [[cpp_std_unordered_map]], and for the second one, I use double pointer method.
|
For the original problem, I thought up an O(m + n) algo, that uses C++'s [[cpp_std_unordered_map]], and for the second one, I use double pointer method.
|
||||||
|
|
||||||
|
> [!tip]
|
||||||
|
> Because elements can be duplicated and we need to know how many, we should use unordered map to store the item's appereance times, (Maybe multiset can work too.)
|
||||||
|
|
||||||
> [!tip] Use [[cpp_std_unordered_map]] for a O(1) hash table when not sorted #tip
|
> [!tip] Use [[cpp_std_unordered_map]] for a O(1) hash table when not sorted #tip
|
||||||
|
|
||||||
> [!tip] Use [[cpp_std_sort]] to sort anything. #tip
|
> [!tip] Use [[cpp_std_sort]] to sort anything. #tip
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
> ##### Additional tags:
|
> ##### Additional tags:
|
||||||
> #leetcode
|
> #leetcode
|
||||||
> ##### Revisions:
|
> ##### Revisions:
|
||||||
> Initial encounter: 2022-06-27
|
> N/A
|
||||||
|
|
||||||
##### Related topics:
|
##### Related topics:
|
||||||
```expander
|
```expander
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
> ##### Additional tags:
|
> ##### Additional tags:
|
||||||
> #<platforms-like-leetcode> #<list-to-be-added>
|
> #<platforms-like-leetcode> #<list-to-be-added>
|
||||||
> ##### Revisions:
|
> ##### Revisions:
|
||||||
> Initial encounter: {{date}}
|
> N/A
|
||||||
> 1st revision: <use-template-command-to-insert-date>
|
|
||||||
|
|
||||||
##### Related topics:
|
##### Related topics:
|
||||||
```expander
|
```expander
|
||||||
|
|
Loading…
Reference in a new issue