随笔分类 -  DP

摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the fo 阅读全文
posted @ 2019-02-12 22:16 Veritas_des_Liberty 阅读(209) 评论(0) 推荐(0)
摘要:Given a string S and a string T, count the number of distinct subsequences of S which equals T. A subsequence of a string is a new string which is for 阅读全文
posted @ 2019-02-11 22:40 Veritas_des_Liberty 阅读(174) 评论(0) 推荐(0)
摘要:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. Example 1: Example 2: Approach #1: DP. [C++] Analysis: status: match[s1L 阅读全文
posted @ 2019-02-11 22:13 Veritas_des_Liberty 阅读(234) 评论(0) 推荐(0)
摘要:Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? Example: Approach #1: DP. [C++] Analysis: status: nums[n] 阅读全文
posted @ 2019-02-11 21:26 Veritas_des_Liberty 阅读(248) 评论(0) 推荐(0)
摘要:We are given N different types of stickers. Each sticker has a lowercase English word on it. You would like to spell out the given target string by cu 阅读全文
posted @ 2019-02-06 23:49 Veritas_des_Liberty 阅读(398) 评论(0) 推荐(0)
摘要:We are given S, a length n string of characters from the set {'D', 'I'}. (These letters stand for "decreasing" and "increasing".) A valid permutation  阅读全文
posted @ 2019-01-30 23:43 Veritas_des_Liberty 阅读(396) 评论(0) 推荐(0)
摘要:In the video game Fallout 4, the quest "Road to Freedom" requires players to reach a metal dial called the "Freedom Trail Ring", and use the dial to s 阅读全文
posted @ 2019-01-30 23:04 Veritas_des_Liberty 阅读(367) 评论(0) 推荐(0)
摘要: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 balloon 阅读全文
posted @ 2019-01-30 22:09 Veritas_des_Liberty 阅读(169) 评论(0) 推荐(0)
摘要:121. Best Time to Buy and Sell Stock Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitte 阅读全文
posted @ 2019-01-05 22:35 Veritas_des_Liberty 阅读(268) 评论(0) 推荐(0)
摘要:Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. Th 阅读全文
posted @ 2018-12-31 21:25 Veritas_des_Liberty 阅读(246) 评论(0) 推荐(0)
摘要:A car travels from a starting position to a destination which is target miles east of the starting position. Along the way, there are gas stations. Ea 阅读全文
posted @ 2018-12-30 21:13 Veritas_des_Liberty 阅读(348) 评论(0) 推荐(0)
摘要:Your car starts at position 0 and speed +1 on an infinite number line. (Your car can go into negative positions.) Your car drives automatically accord 阅读全文
posted @ 2018-12-23 18:57 Veritas_des_Liberty 阅读(334) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-12-16 17:58 Veritas_des_Liberty 阅读(340) 评论(0) 推荐(0)
摘要:Given an integer matrix, find the length of the longest increasing path. From each cell, you can either move to four directions: left, right, up or do 阅读全文
posted @ 2018-12-11 13:11 Veritas_des_Liberty 阅读(240) 评论(0) 推荐(0)
摘要:Given an array A of strings, find any smallest string that contains each string in A as a substring. We may assume that no string in A is substring of 阅读全文
posted @ 2018-11-18 21:48 Veritas_des_Liberty 阅读(286) 评论(0) 推荐(0)
摘要:There are two types of soup: type A and type B. Initially we have N ml of each type of soup. There are four kinds of operations: When we serve some so 阅读全文
posted @ 2018-11-17 15:49 Veritas_des_Liberty 阅读(253) 评论(0) 推荐(0)
摘要:Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays. Example 1: Note: Approach #1: Dynamic programm 阅读全文
posted @ 2018-11-08 21:08 Veritas_des_Liberty 阅读(194) 评论(0) 推荐(0)
摘要:Given an integer array, return the k-th smallest distance among all the pairs. The distance of a pair (A, B) is defined as the absolute difference bet 阅读全文
posted @ 2018-11-08 20:48 Veritas_des_Liberty 阅读(207) 评论(0) 推荐(0)
摘要:Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algor 阅读全文
posted @ 2018-11-06 20:28 Veritas_des_Liberty 阅读(187) 评论(0) 推荐(0)
摘要:The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 阅读全文
posted @ 2018-11-03 17:16 Veritas_des_Liberty 阅读(240) 评论(0) 推荐(0)