일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 파이썬
- 문자열
- CS
- lightsailor
- computerscience
- node.js
- typescript
- 배포
- Local Search
- 코드
- Search Algorithm
- multer-s3
- Hill Climbing
- 컴퓨터과학
- node배포
- 알고리즘
- AWS
- 컴퓨터공학
- 문자열처리
- 철학
- Simulated Annealing
- Today
- Total
목록PS/LeetCode (9)
지식의모듈화
/** * @param {number[]} nums * @return {boolean} */ var canJump = function(nums) { let atLeastReach = nums.length-1 //4 for(let i= nums.length-2; i>=0 ; i--){ if (i+nums[i] >= atLeastReach){ atLeastReach = i } } return atLeastReach == 0 }; 마지막 배열에 닿을 수 있는지 뒤에서부터 생각하면 된다!
/** * @param {number[]} nums * @return {number[]} */ var findDuplicates = function(nums) { const ans=[]; for(let i=0;i
1. DP solution /** * @param {number[]} nums * @return {boolean} */ var canJump = function(nums) { let i=nums.length-1; const jumps= new Array(nums.length).fill(false); jumps[i]=true; for (;i>=0;i--){ let max = Math.min(i+nums[i], nums.length-1) for(let j=i; max>=j;j++){ if(jumps[j]){ jumps[i]=true; } } } return jumps[0] }; 2. Greedy Solution var canJump = function(nums) { let index=nums.length-1..
1. 1개의 Set사용 /** * @param {character[][]} board * @return {boolean} */ var isValidSudoku = function(board) { let set= new Set(); for (let i=0; i
141. Linked List Cycle /** * Definition for singly-linked list. * function ListNode(val) { * this.val = val; * this.next = null; * } */ /** * @param {ListNode} head * @return {boolean} */ var hasCycle = function(head) { let fast= head; let ans=false; while(fast&&fast.next&&head){ head=head.next fast=fast.next.next if(head===fast) { ans=true; break; } } return ans };
46. Permutations /** * @param {number[]} nums * @return {number[][]} */ var permute = function(nums) { let visited= new Array(nums.length).fill(false); const ans =[]; function dfs(current){ if (current.length===nums.length){ ans.push(current); } for(let i=0;i
98. Validate Binary Search Tree /** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val===undefined ? 0 : val) * this.left = (left===undefined ? null : left) * this.right = (right===undefined ? null : right) * } */ /** * @param {TreeNode} root * @return {boolean} */ var isValidBST = function(root) { // console.log(root.left, root.right, root, "VALID"); ..
Problem 77 [Easy] This problem was asked by Snapchat. Given a list of possibly overlapping intervals, return a new list of intervals where all overlapping intervals have been merged. The input list is not necessarily ordered in any way. For example, given [(1, 3), (5, 8), (4, 10), (20, 25)], you should return [(1, 3), (4, 10), (20, 25)]. //Problem 77 [Easy] function answer(arr){ const ans=[]; ar..