File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * @lc app=leetcode.cn id=2032 lang=javascript
3
+ *
4
+ * [2032] 至少在两个数组中出现的值
5
+ */
6
+
7
+ // @lc code=start
8
+ /**
9
+ * @param {number[] } nums1
10
+ * @param {number[] } nums2
11
+ * @param {number[] } nums3
12
+ * @return {number[] }
13
+ */
14
+ var twoOutOfThree = function ( nums1 , nums2 , nums3 ) {
15
+ const result = [ ] ;
16
+ const s1 = new Set ( nums1 ) ;
17
+ const s2 = new Set ( nums2 ) ;
18
+
19
+ for ( let i = 0 ; i < nums2 . length ; i ++ ) {
20
+ if ( s1 . has ( nums2 [ i ] ) ) {
21
+ result . push ( nums2 [ i ] ) ;
22
+ }
23
+ }
24
+ for ( let i = 0 ; i < nums3 . length ; i ++ ) {
25
+ if ( s1 . has ( nums3 [ i ] ) ) {
26
+ result . push ( nums3 [ i ] ) ;
27
+ }
28
+ }
29
+ for ( let i = 0 ; i < nums3 . length ; i ++ ) {
30
+ if ( s2 . has ( nums3 [ i ] ) ) {
31
+ result . push ( nums3 [ i ] ) ;
32
+ }
33
+ }
34
+ return [ ...new Set ( result ) ] ;
35
+ } ;
36
+ // @lc code=end
37
+
You can’t perform that action at this time.
0 commit comments