随笔分类 - 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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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]
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文

浙公网安备 33010602011771号