File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 175
175
| 1780| [ 判断一个数字是否可以表示成三的幂的和] ( https://leetcode.cn/problems/check-if-number-is-a-sum-of-powers-of-three/ ) | [ JavaScript] ( ./algorithms/check-if-number-is-a-sum-of-powers-of-three.js ) | Medium|
176
176
| 1832| [ 判断句子是否为全字母句] ( https://leetcode.cn/problems/check-if-the-sentence-is-pangram/ ) | [ JavaScript] ( ./algorithms/check-if-the-sentence-is-pangram.js ) | Easy|
177
177
| 1945| [ 字符串转化后的各位数字之和] ( https://leetcode.cn/problems/sum-of-digits-of-string-after-convert/ ) | [ JavaScript] ( ./algorithms/sum-of-digits-of-string-after-convert.js ) | Easy|
178
+ | 2032| [ 至少在两个数组中出现的值] ( https://leetcode.cn/problems/two-out-of-three/ ) | [ JavaScript] ( ./algorithms/two-out-of-three.js ) | Easy|
178
179
| 面试题 04.12| [ 面试题 04.12. 求和路径] ( https://leetcode.cn/problems/paths-with-sum-lcci/ ) | [ JavaScript] ( ./algorithms/paths-with-sum-lcci.js ) | Medium|
179
180
| 面试题 02.07| [ 面试题 02.07. 链表相交] ( https://leetcode.cn/problems/intersection-of-two-linked-lists-lcci/ ) | [ JavaScript] ( ./algorithms/intersection-of-two-linked-lists-lcci.js ) | Easy|
180
181
| 剑指 Offer 05. 替换空格| [ 剑指 Offer 05. 替换空格] ( https://leetcode.cn/problems/ti-huan-kong-ge-lcof/ ) | [ JavaScript] ( ./algorithms/ti-huan-kong-ge-lcof.js ) | Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number[] } nums1
3
+ * @param {number[] } nums2
4
+ * @param {number[] } nums3
5
+ * @return {number[] }
6
+ */
7
+ var twoOutOfThree = function ( nums1 , nums2 , nums3 ) {
8
+ const result = [ ] ;
9
+ const s1 = new Set ( nums1 ) ;
10
+ const s2 = new Set ( nums2 ) ;
11
+
12
+ for ( let i = 0 ; i < nums2 . length ; i ++ ) {
13
+ if ( s1 . has ( nums2 [ i ] ) ) {
14
+ result . push ( nums2 [ i ] ) ;
15
+ }
16
+ }
17
+ for ( let i = 0 ; i < nums3 . length ; i ++ ) {
18
+ if ( s1 . has ( nums3 [ i ] ) ) {
19
+ result . push ( nums3 [ i ] ) ;
20
+ }
21
+ }
22
+ for ( let i = 0 ; i < nums3 . length ; i ++ ) {
23
+ if ( s2 . has ( nums3 [ i ] ) ) {
24
+ result . push ( nums3 [ i ] ) ;
25
+ }
26
+ }
27
+ return [ ...new Set ( result ) ] ;
28
+ } ;
You can’t perform that action at this time.
0 commit comments