- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 245
[HerrineKim] Week 4 #826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    [HerrineKim] Week 4 #826
Changes from all commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      6c8cc95
              
                add: missing-number
              
              
                HerrineKim e6cab98
              
                fix: lint
              
              
                HerrineKim 021d8fe
              
                fix: 시간 복잡도
              
              
                HerrineKim 3ce1527
              
                fix: 시간 복잡도 개선
              
              
                HerrineKim 6ccf94c
              
                add: 가우스 공식 사용해 공간 복잡도 개선
              
              
                HerrineKim 0716dae
              
                add: coin-change
              
              
                HerrineKim a7eff01
              
                fix: lint
              
              
                HerrineKim e051a94
              
                add: palindromic-substrings
              
              
                HerrineKim File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // 시간 복잡도: O(n * m) | ||
| // 공간 복잡도: O(n) | ||
|  | ||
| /** | ||
| * @param {number[]} coins | ||
| * @param {number} amount | ||
| * @return {number} | ||
| */ | ||
| var coinChange = function(coins, amount) { | ||
| const dp = new Array(amount + 1).fill(Infinity); | ||
| dp[0] = 0; | ||
|  | ||
| for (let coin of coins) { | ||
| for (let i = coin; i <= amount; i++) { | ||
| dp[i] = Math.min(dp[i], dp[i - coin] + 1); | ||
| } | ||
| } | ||
|  | ||
| return dp[amount] === Infinity ? -1 : dp[amount]; | ||
| }; | ||
|  | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // 시간 복잡도: O(n) | ||
| // 공간 복잡도: O(1) | ||
|  | ||
| /** | ||
| * @param {number[]} nums | ||
| * @return {number} | ||
| */ | ||
| var missingNumber = function(nums) { | ||
| const n = nums.length; | ||
| // 0부터 n까지의 합 공식: n * (n + 1) / 2 | ||
| const expectedSum = (n * (n + 1)) / 2; | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제가 리뷰 의도드린 대로 풀어주셨네요! 👍 | ||
| // 실제 배열의 합 | ||
| const actualSum = nums.reduce((sum, num) => sum + num, 0); | ||
|  | ||
| return expectedSum - actualSum; | ||
| }; | ||
|  | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // 시간 복잡도: O(n^2) | ||
| // 공간 복잡도: O(1) | ||
|  | ||
| /** | ||
| * @param {string} s | ||
| * @return {number} | ||
| */ | ||
| var countSubstrings = function(s) { | ||
| let count = 0; | ||
|  | ||
| const countPalindrome = (left, right) => { | ||
| while (left >= 0 && right < s.length && s[left] === s[right]) { | ||
| count++; | ||
| left--; | ||
| right++; | ||
| } | ||
| }; | ||
|  | ||
| for (let i = 0; i < s.length; i++) { | ||
| countPalindrome(i, i); | ||
| countPalindrome(i, i + 1); | ||
| } | ||
|  | ||
| return count; | ||
| }; | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dp 로 잘 풀어주셨네요! 👍