随笔分类 -  dfs + memo/ dp

96. Unique Binary Search Trees
摘要:96. Unique Binary Search Trees https://leetcode.com/problems/unique-binary-search-trees/discuss/31666/DP-Solution-in-6-lines-with-explanation.-F(i-n)-G(i-1)-*-G(n-i) Given n, how many structurally... 阅读全文

posted @ 2018-11-09 10:40 猪猪🐷

161. One Edit Distance
摘要:Given two strings s and t, determine if they are both one edit distance apart. Note: There are 3 possiblities to satisify one edit distance apart: Insert a character into s to get t Delete a char... 阅读全文

posted @ 2018-11-09 07:22 猪猪🐷

568. Maximum Vacation Days
摘要:需要把这道题从brute force 分析, 然后找到重复的计算, 然后一步步优化, 一直到 一维dp. 分析时间复杂度 https://www.youtube.com/watch?v=_MYkrCfFb4M LeetCode wants to give one of its best employees the option to travel among N cities to c... 阅读全文

posted @ 2018-11-08 17:02 猪猪🐷

312. Burst Balloons
摘要:Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get nums[l... 阅读全文

posted @ 2018-11-08 16:33 猪猪🐷

724. Find Pivot Index
摘要:Given an array of integers nums, write a method that returns the "pivot" index of this array. We define the pivot index as the index where the sum of 阅读全文

posted @ 2018-11-08 16:12 猪猪🐷

548. Split Array with Equal Sum
摘要:Given an array with n integers, you need to find if there are triplets (i, j, k) which satisfies following conditions: 1. 0 set = new HashSet(); // cut left , i for(int i = ... 阅读全文

posted @ 2018-11-08 02:26 猪猪🐷

418. Sentence Screen Fitting
摘要:Given a rows x cols screen and a sentence represented by a list of non-empty words, find how many times the given sentence can be fitted on the screen 阅读全文

posted @ 2018-11-08 02:21 猪猪🐷

241. Different Ways to Add Parentheses
摘要:Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *. Example 1: Inpu... 阅读全文

posted @ 2018-11-06 09:30 猪猪🐷

403. Frog Jump
摘要:https://www.youtube.com/watch?v=-FBfrVz841k https://leetcode.com/problems/frog-jump/solution/ A frog is crossing a river. The river is divided into x units and at each unit there may or may not... 阅读全文

posted @ 2018-11-06 07:47 猪猪🐷

361. Bomb Enemy
摘要:Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return the maximum enemies you can kill using one bomb.
The bomb kills all the enemies in the same row an... 阅读全文

posted @ 2018-11-06 07:46 猪猪🐷

472. Concatenated Words
摘要:Given a list of words (without duplicates), please write a program that returns all concatenated words in the given list of words. A concatenated word is defined as a string that is comprised entirel... 阅读全文

posted @ 2018-11-06 07:36 猪猪🐷

568. Maximum Vacation Days
摘要:LeetCode wants to give one of its best employees the option to travel among N cities to collect algorithm problems. But all work and no play makes Jack a dull boy, you could take vacations in some pa... 阅读全文

posted @ 2018-09-25 04:21 猪猪🐷

485. Max Consecutive Ones
摘要:485. Max Consecutive Ones Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last thre... 阅读全文

posted @ 2018-09-20 18:09 猪猪🐷

32. Longest Valid Parentheses
摘要:Longest Valid Parentheses https://www.youtube.com/watch?v=M1Vw5Tk1rw4 阅读全文

posted @ 2018-08-09 17:23 猪猪🐷

导航