Notice
                              
                          
                        
                          
                          
                            Recent Posts
                            
                        
                          
                          
                            Recent Comments
                            
                        
                          
                          
                            Link
                            
                        
                    | 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 | 
| 12 | 13 | 14 | 15 | 16 | 17 | 18 | 
| 19 | 20 | 21 | 22 | 23 | 24 | 25 | 
| 26 | 27 | 28 | 29 | 30 | 31 | 
                            Tags
                            
                        
                          
                          - 티스토리 성능
- github pdf
- vercel git lfs
- animation
- ffi-napi
- adb pair
- electron-packager
- github 100mb
- react-native-dotenv
- device in use
- nextjs
- augmentedDevice
- Recoil
- 이미지 데이터 타입
- rolldown
- camera permission
- custom printing
- github lfs
- react-native
- html
- ELECTRON
- Git
- silent printing
- Can't resolve
- adb connect
- Failed to compiled
- Each child in a list should have a unique "key" prop.
- dvh
- npm package
- camera access
                            Archives
                            
                        
                          
                          - Today
- Total
Bleeding edge
[LeetCode] 2032. Two Out of Three - 자바스크립트 0628 본문
https://leetcode.com/problems/two-out-of-three/
Two Out of Three - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
3개의 array에 한번이라도 겹치는 경우가 있다면 그것을 리턴하는 문제이다.
1. 1번에 있는 숫자중에서, 2번 혹은 3번에 있는 숫자를 필터한다
    const filteredNum1 = nums1.filter((x) => nums2.includes(x) || nums3.includes(x))2. 2번에 있는 숫자중에서 3번에 있으나, filteredNum1에는 없는 숫자를 구한다
    const filteredNum2 = nums2.filter((x) => nums3.includes(x) && !filteredNum1.includes(x))3. set리스트에 넣어서 중복을 줄인다
    const answer = new Set([...filteredNum1.concat(filteredNum2)])
4. Array로 리턴한다
    return Array.from(answer)
전체풀이
var twoOutOfThree = function (nums1, nums2, nums3) {
        const filteredNum1 = nums1.filter((x) => nums2.includes(x) || nums3.includes(x))
    const filteredNum2 = nums2.filter((x) => nums3.includes(x) && !filteredNum1.includes(x))
    const answer = new Set([...filteredNum1.concat(filteredNum2)])
    return Array.from(answer)
};'코딩테스트 공부' 카테고리의 다른 글
| [LeetCode] 1447. Simplified Fractions - 자바스크립트 0628 (0) | 2022.06.28 | 
|---|---|
| [LeetCode] 2180. Count Integers With Even Digit Sum - 자바스크립트 0628 (0) | 2022.06.28 | 
| [LeetCode] 2225. Find Players With Zero or One Losses - 자바스크립트 0627 (0) | 2022.06.27 | 
| [LeetCode] 2129. Capitalize the Title - 자바스크립트 0627 (0) | 2022.06.27 | 
| [LeetCode] 1578. Minimum Time to Make Rope Colorful - 자바스크립트 0624 (0) | 2022.06.24 | 
 
          