
DP
Frontier_Setter
这个作者很懒,什么都没留下…
展开
-
USACO 5.5.3 Twofive 记忆式搜索+枚举
http://train.usaco.org/usacoprob2?a=qNexyVCSx2z&S=twofive题目大意:给一个5*5的字符方阵(A-Z),阅读顺序为从上到下逐行从左到右念下来,要求每一个位置的字母比它上方与左侧的字母要大。题目有两个要求:1、给一个方阵求它在所有可能的方阵中排第几个(按字典序升序排列)2、给序号,求出方阵1、要枚举的话有25!种情况,肯定不是这么搞的2、...原创 2018-02-09 23:50:25 · 388 阅读 · 0 评论 -
[LeetCode] (medium) 516. Longest Palindromic Subsequence
https://leetcode.com/problems/longest-palindromic-subsequence/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...原创 2019-05-18 20:30:54 · 127 阅读 · 0 评论 -
[LeetCode] (medium) 494. Target Sum
https://leetcode.com/problems/target-sum/You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols+and-. For each integer, you should choose one fro...原创 2019-05-16 17:25:44 · 124 阅读 · 0 评论 -
[LeetCode] (medium) 416. Partition Equal Subset Sum
https://leetcode.com/problems/partition-equal-subset-sum/Given anon-emptyarray containingonly positive integers, find if the array can be partitioned into two subsets such that the sum of elemen...原创 2019-04-30 12:27:24 · 310 阅读 · 0 评论 -
[LeetCode] (medium) 375. Guess Number Higher or Lower II
We are playing the Guess Game. The game is as follows:I pick a number from1ton. You have to guess which number I picked.Every time you guess wrong, I'll tell you whether the number I picked is...原创 2019-04-07 00:33:43 · 138 阅读 · 0 评论 -
[LeetCode] (medium) 309. Best Time to Buy and Sell Stock with Cooldown
https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the ...转载 2019-04-01 16:06:05 · 158 阅读 · 0 评论 -
[LeetCode] (medium) 63. Unique Paths II
https://leetcode.com/problems/unique-paths-ii/submissions/A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or ri...原创 2019-02-26 22:17:28 · 158 阅读 · 0 评论 -
[LeetCode] (medium) 120. Triangle
https://leetcode.com/problems/triangle/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 following...原创 2019-03-02 20:40:39 · 222 阅读 · 0 评论 -
[LeetCode] (medium) 91. Decode Ways
https://leetcode.com/problems/decode-ways/A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given a non-emp...原创 2019-02-13 17:08:39 · 145 阅读 · 0 评论 -
[LeetCode] (medium) 322. Coin Change
https://leetcode.com/problems/coin-change/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 you need to ...原创 2019-02-18 15:04:39 · 603 阅读 · 0 评论 -
[LeetCode] (medium) 279. Perfect Squares
https://leetcode.com/problems/perfect-squares/Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.Example 1:Input: n = 12...原创 2019-02-17 22:57:04 · 163 阅读 · 0 评论 -
[LeetCode] (medium) 152. Maximum Product Subarray
https://leetcode.com/problems/maximum-product-subarray/Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.Exa...原创 2019-02-16 19:37:07 · 116 阅读 · 0 评论 -
[LeetCode] (medium) 139. Word Break
https://leetcode.com/problems/word-break/Given a non-empty string s and a dictionary wordDict containing a list of non-emptywords, determine if s can be segmented into a space-separated sequence of...原创 2019-02-15 20:30:46 · 187 阅读 · 0 评论 -
USACO 5.4 Character Recognition
原创 2018-02-08 00:58:35 · 434 阅读 · 0 评论 -
USACO 6.1.1 Postal Vans 特例dp
http://train.usaco.org/usacoprob2?a=iHzQON4VeJX&S=vans题目大意:由4条横线,N条纵线划划分的网络,要求一条路线经过每个网点一次且仅一次,求共有多少条这样的路径想法一:枚举,不可能,其实到第五章之后的题目好像都不太能枚举了想法二:相当于先有一个最外层的大矩形轮廓,然后逐步“下凹”,只要下凹的那一格在当前外表面轮廓组成中只有一条边就不会使最...原创 2018-02-10 20:57:14 · 505 阅读 · 0 评论 -
[LeetCode] (medium) 688. Knight Probability in Chessboard
https://leetcode.com/problems/knight-probability-in-chessboard/On anNxNchessboard, a knight starts at ther-th row andc-th column and attempts to make exactlyKmoves. The rows and columns are 0...原创 2019-05-31 22:00:16 · 161 阅读 · 0 评论