
动态规划
景行cmy
这个作者很懒,什么都没留下…
展开
-
leetcode 568. Maximum Vacation Days
LeetCode wants to give one of its best employees the option to travel amongNcities to collect algorithm problems. But all work and no play makes Jack a dull boy, you could take vacations in some par...原创 2019-10-30 09:31:46 · 244 阅读 · 0 评论 -
leetcode 903. Valid Permutations for DI Sequence
We are givenS, a lengthnstring of characters from the set{'D', 'I'}. (These letters stand for "decreasing" and "increasing".)Avalid permutationis a permutationP[0], P[1], ..., P[n]of integer...原创 2019-08-29 11:40:16 · 500 阅读 · 0 评论 -
leetcode 920. Number of Music Playlists
Your music player containsNdifferent songs and she wants to listen toL(not necessarily different) songs during your trip. Youcreatea playlist sothat:Every song is played at least once A son...原创 2019-08-29 15:39:19 · 151 阅读 · 0 评论 -
leetcode 960. Delete Columns to Make Sorted III
We are given an arrayAofNlowercase letter strings, all of the same length.Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.For...原创 2019-08-29 21:25:09 · 179 阅读 · 0 评论 -
leetcode 975. Odd Even Jump
You are given an integer arrayA. Fromsome starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...)jumps in the series are calledodd numbered jumps, and the (2nd, 4th, 6th, ...) j...原创 2019-09-06 10:46:35 · 140 阅读 · 0 评论 -
leetcode 964. Least Operators to Express Number
Given a single positive integerx, we will write an expression of the formx (op1) x (op2) x (op3) x ...where each operatorop1,op2, etc. is either addition, subtraction, multiplication, or division...原创 2019-09-06 14:33:02 · 344 阅读 · 0 评论 -
leetcode 1000. Minimum Cost to Merge Stones
There areNpiles of stones arranged in a row. Thei-th pile hasstones[i]stones.Amoveconsists of mergingexactlyKconsecutivepiles into one pile, and the cost of this move is equal to the tot...原创 2019-09-06 18:29:38 · 243 阅读 · 0 评论 -
leetcode 1092. 最短公共超序列
给出两个字符串 str1 和 str2,返回同时以 str1 和 str2 作为子序列的最短字符串。如果答案不止一个,则可以返回满足条件的任意一个答案。(如果从字符串 T 中删除一些字符(也可能不删除,并且选出的这些字符可以位于 T 中的 任意位置),可以得到字符串 S,那么 S 就是 T 的子序列)示例:输入:str1 = "abac", str2 = "cab"输出:"ca...原创 2019-09-07 11:59:57 · 1935 阅读 · 1 评论 -
leetcode 1125. Smallest Sufficient Team
In a project, you have a list of required skills req_skills,and a list of people. The i-th person people[i]contains a list of skills that person has.Consider a sufficient team: a set of people su...原创 2019-09-09 15:39:17 · 289 阅读 · 0 评论 -
leetcode 1187. Make Array Strictly Increasing
Given two integer arraysarr1 and arr2, return the minimum number of operations (possibly zero) neededto make arr1 strictly increasing.In one operation, you can choose two indices0 <=i < ar...原创 2019-09-09 19:36:37 · 504 阅读 · 0 评论 -
879. Profitable Schemes
There are G people in a gang, and a list of various crimes they could commit.Thei-th crime generates aprofit[i]and requiresgroup[i]gang members to participate.If a gang member participates in ...原创 2019-08-28 19:12:39 · 180 阅读 · 0 评论 -
leetcode 871. Minimum Number of Refueling Stops
A car travels from a starting position to a destination which istargetmiles east of the starting position.Along the way, there are gas stations. Eachstation[i]represents a gas station that iss...原创 2019-08-28 11:53:22 · 135 阅读 · 0 评论 -
leetcode 828. Unique Letter String
A character is unique in stringSif it occurs exactly once in it.For example, in stringS = "LETTER", the only unique characters are"L"and"R".Let's defineUNIQ(S)as the number of unique chara...原创 2019-08-26 21:00:53 · 234 阅读 · 0 评论 -
leetcode 664. Strange Printer
There is a strange printer with the following two special requirements:The printer can only print a sequence of the same character each time. At each turn, the printer can print new characters star...原创 2019-07-12 07:58:16 · 94 阅读 · 0 评论 -
leetcode 600. Non-negative Integers without Consecutive Ones
Given a positive integer n, find the number ofnon-negativeintegers less than or equal to n, whose binary representations do NOT containconsecutive ones.Example 1:Input: 5Output: 5Explanation...原创 2019-07-24 17:18:37 · 159 阅读 · 0 评论 -
leetcode 87. Scramble String
Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation ofs1="great": great / \ gr ...转载 2019-07-20 13:19:09 · 311 阅读 · 0 评论 -
leetcode 691. Stickers to Spell Word
We are given N different types of stickers. Each sticker has a lowercase English word on it.You would like to spell out the giventargetstring by cutting individual letters from your collection of ...原创 2019-07-25 14:26:10 · 219 阅读 · 0 评论 -
leetcode 629. K Inverse Pairs Array
Given two integersnandk, find how many different arrays consist of numbers from1tonsuch that there are exactlykinverse pairs.We define an inverse pair as following: Forithandjthelement i...原创 2019-07-25 17:19:16 · 95 阅读 · 0 评论 -
leetcode 639. Decode Ways II
A message containing letters fromA-Zis being encoded to numbers using the following mapping way:'A' -> 1'B' -> 2...'Z' -> 26Beyond that, now the encoded string can also contain the...原创 2019-07-26 09:04:23 · 100 阅读 · 0 评论 -
leetcode 132. Palindrome Partitioning II
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs.Example:Input:"aab"Output: 1Explana...原创 2019-08-07 13:58:57 · 83 阅读 · 0 评论 -
leetcode 741. Cherry Pickup
In a N x Ngridrepresenting a field of cherries, each cell is one of three possible integers.0 means the cell is empty, so you can pass through; 1 means the cell contains a cherry, that you can...原创 2019-08-19 15:48:08 · 188 阅读 · 0 评论 -
leetcode 446. Arithmetic Slices II - Subsequence
A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic sequence...原创 2019-08-14 20:02:32 · 141 阅读 · 0 评论 -
leetcode 805. Split Array With Same Average
In a given integer array A, we must move every element of A to either list B or list C. (B and C initially start empty.)Return true if and only if after such a move, it is possible that the average ...原创 2019-08-24 17:16:19 · 165 阅读 · 0 评论 -
leetcode 730 Count Different Palindromic Subsequences
Given a string S, find the number of different non-empty palindromic subsequences in S, andreturn that number modulo10^9 + 7.A subsequence of a string S is obtained by deleting 0 or more character...原创 2019-08-15 22:00:43 · 177 阅读 · 0 评论 -
leetcode 546 Remove Boxes
Given several boxes with different colors represented by different positive numbers.You may experience several rounds to remove boxes until there is no box left. Each time you can choose some contin...原创 2019-07-11 11:21:03 · 308 阅读 · 0 评论