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 | 
                            Tags
                            
                        
                          
                          - Git
- Recoil
- nextjs
- animation
- Can't resolve
- npm package
- github lfs
- 이미지 데이터 타입
- ELECTRON
- Failed to compiled
- adb pair
- camera permission
- rolldown
- vercel git lfs
- ffi-napi
- html
- adb connect
- augmentedDevice
- device in use
- github pdf
- silent printing
- camera access
- react-native-dotenv
- dvh
- Each child in a list should have a unique "key" prop.
- react-native
- electron-packager
- 티스토리 성능
- github 100mb
- custom printing
                            Archives
                            
                        
                          
                          - Today
- Total
Bleeding edge
[LeetCode] 2225. Find Players With Zero or One Losses - 자바스크립트 0627 본문
      코딩테스트 공부
      
    [LeetCode] 2225. Find Players With Zero or One Losses - 자바스크립트 0627
codevil 2022. 6. 27. 13:40https://leetcode.com/problems/find-players-with-zero-or-one-losses/
Find Players With Zero or One Losses - 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
1. hash map과 return 할 result를 만든다
    const hash = {}
    const result = [[], []]2. 주어진 matches에서 갯수를 카운팅한다
    matches.map(([win, lose]) => {
        hash[win] = (hash[win] || 0); hash[lose] = (hash[lose] || 0) + 1
    })3. key의 값이 0이면 result[0] 1이면 result[1]에 push후 return 한다
    for (let key in hash) {
        if (hash[key] === 0) {
            result[0].push(Number(key))
        } else if (hash[key] === 1) {
            result[1].push(Number(key))
        }
    }
    return result전체 풀이
var findWinners = function (matches) {
    const hash = {}
    const result = [[], []]
    matches.map(([win, lose]) => {
        hash[win] = (hash[win] || 0); hash[lose] = (hash[lose] || 0) + 1
    })
    for (let key in hash) {
        if (hash[key] === 0) {
            result[0].push(Number(key))
        } else if (hash[key] === 1) {
            result[1].push(Number(key))
        }
    }
    return result
};'코딩테스트 공부' 카테고리의 다른 글
| [LeetCode] 2180. Count Integers With Even Digit Sum - 자바스크립트 0628 (0) | 2022.06.28 | 
|---|---|
| [LeetCode] 2032. Two Out of Three - 자바스크립트 0628 (0) | 2022.06.28 | 
| [LeetCode] 2129. Capitalize the Title - 자바스크립트 0627 (0) | 2022.06.27 | 
| [LeetCode] 1578. Minimum Time to Make Rope Colorful - 자바스크립트 0624 (0) | 2022.06.24 | 
| [LeetCode] 2269. Find the K-Beauty of a Number - 자바스크립트 0624 (0) | 2022.06.24 | 
 
          