Created
          December 7, 2020 17:48 
        
      - 
      
- 
        Save iJustErikk/7916c676b74052717a313624a3829622 to your computer and use it in GitHub Desktop. 
  
    
      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
    
  
  
    
  | const canSum = (goal, nums) => { | |
| const table = new Array(goal + 1).fill(false); | |
| table[0] = true; | |
| for (let i = 0; i <= goal; i += 1) { | |
| // i is current value | |
| // if i is true, then i + nums[j] is also true | |
| if (table[i]) { | |
| for (let j = 0; j < nums.length; j += 1) { | |
| const currentVal = i + nums[j]; | |
| if (currentVal <= goal) table[currentVal] = true; | |
| } | |
| } | |
| } | |
| return table[goal]; | |
| }; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment