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
                            
                        
                          
                          - adb connect
- github pdf
- 티스토리 성능
- camera access
- react-native-dotenv
- Recoil
- github 100mb
- custom printing
- 이미지 데이터 타입
- Failed to compiled
- npm package
- ffi-napi
- rolldown
- device in use
- vercel git lfs
- camera permission
- animation
- electron-packager
- Can't resolve
- dvh
- Git
- github lfs
- adb pair
- react-native
- silent printing
- nextjs
- html
- augmentedDevice
- Each child in a list should have a unique "key" prop.
- ELECTRON
                            Archives
                            
                        
                          
                          - Today
- Total
Bleeding edge
[LeetCode] 2269. Find the K-Beauty of a Number - 자바스크립트 0624 본문
https://leetcode.com/problems/find-the-k-beauty-of-a-number/
Find the K-Beauty of a Number - 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
주어진 k의 길이만큼 nums를 자르고, 자르고 나온 숫자가 x라고 했을때 x가 num로 나누었을 때 0인 경우의 수를 세는 문제이다. 아마 풀이를 보는게 더 이해가 빠를것 같다.
1. 0인 ansewr와 array인 return을 선언한다. 그리고 num을 slice시키기 위해 nums로 만든다
    let answer = 0
    const result = []
    const nums = num + ""
2. for 문을 이용하여, nums를 구간구간 자르고, result로 push한다
    for (let i = 0; i < nums.length - k + 1; i++) {
        result.push(Number(nums.slice(i, k + i)))
    }3. result에 map을 이용하여, num%nums[i]가 0일 때 answer을 1을 더해준다.
    result.map((me) => {
        if (num % me === 0) {
            answer++
        }
    })4. answer를 return 한다
전체 풀이
var divisorSubstrings = function (num, k) {
    let answer = 0
    const result = []
    const nums = num + ""
    for (let i = 0; i < nums.length - k + 1; i++) {
        result.push(Number(nums.slice(i, k + i)))
    }
    result.map((me) => {
        if (num % me === 0) {
            answer++
        }
    })
    return answer
};'코딩테스트 공부' 카테고리의 다른 글
| [LeetCode] 2129. Capitalize the Title - 자바스크립트 0627 (0) | 2022.06.27 | 
|---|---|
| [LeetCode] 1578. Minimum Time to Make Rope Colorful - 자바스크립트 0624 (0) | 2022.06.24 | 
| [LeetCode] 1051. Height Checker - 자바스크립트 0624 (0) | 2022.06.24 | 
| [LeetCode] 2288. Apply Discount to Prices - 자바스크립트 0623 (0) | 2022.06.23 | 
| [LeetCode] 338. Counting Bits - 자바스크립트 - 0623 (0) | 2022.06.23 | 
 
          