Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6.
Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most two transactions. Note: You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again). Find the maximum … [Read more…]
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a word: a) Insert a character b) Delete a character c) Replace a character Find minimum number of steps, then it must be a Dynamic Programming problem. Only … [Read more…]
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s = “leetcode”, dict = [“leet”, “code”]. Return true because “leetcode” can be segmented as “leet code”. Most of problems that return a bool value or int value (amount) in LeetCode can be solved using Dynamic Programming.
In last week Computational Photography class, Rob showed us a video about seam carving, which is really awesome, like magic. During my last bachelor year, I published a paper with my group named “Semantic aware sport image resizing jointly using seam carving and warping”, I worked for the sport image field detection part. So when … [Read more…]