随笔分类 - Dynamic Programming
摘要:You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return
阅读全文
摘要:There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. Yo
阅读全文
摘要:[抄题]: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place
阅读全文
摘要:[抄题]: On an NxN chessboard, a knight starts at the r-th row and c-th column and attempts to make exactly Kmoves. The rows and columns are 0 indexed, s
阅读全文
摘要:[抄题]: You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that y
阅读全文
摘要:[抄题]: You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can fol
阅读全文
摘要:[抄题]: The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, ea
阅读全文
摘要:[抄题]: Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000. Example 1:Input:
阅读全文
摘要:[抄题]: There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is differe
阅读全文
摘要:[抄题]: In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum. Each subarray will be of size k, and we want
阅读全文
摘要:[抄题]: Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'. The matching should cover the ent
阅读全文
摘要:[抄题]: We have two integer sequences A and B of the same non-zero length. We are allowed to swap elements A[i] and B[i]. Note that both elements are in
阅读全文
摘要:[抄题]: 求挖掉一些区域后,能允许出现的最大十字架 In a 2D grid from (0, 0) to (N-1, N-1), every cell contains a 1, except those cells in the given list mines which are 0. Wh
阅读全文
摘要:[抄题]: Given an unsorted array of integers, find the number of longest increasing subsequence. Example 1: Example 2: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空
阅读全文
摘要:[抄题]: Your are given an array of integers prices, for which the i-th element is the price of a given stock on day i; and a non-negative integer fee re
阅读全文
摘要:[抄题]: A message containing letters from A-Z is being encoded to numbers using the following mapping: Given a non-empty string containing only digits,
阅读全文
摘要:[抄题]: Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes
阅读全文
摘要:[抄题]: Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'. The matching should cover the e
阅读全文
摘要:[抄题]: There is a fence with n posts, each post can be painted with one of the k colors. You have to paint all the posts such that no more than two adj
阅读全文
摘要:[抄题]: There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a
阅读全文