LeeCode_dynamic programming
Haskei
这个作者很懒,什么都没留下…
展开
-
腾讯笔试:构造回文(使用最长公共子序列) 动态规划
[编程题]构造回文 热度指数:32720时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32M,其他语言64M 链接:https://www.nowcoder.com/questionTerminal/28c1dc06bc9b4afd957b01acdf046e69 来源:牛客网 给定一个字符串s,你可以从中删除一些字符,使得剩下的串是一个回文串。如何删除才能使得回文串最长呢? 输出需要删除的字符个数。 输入描述: 输入数据有多组,每组包含一个字符串s,且保证:1<=...原创 2020-08-22 14:34:08 · 194 阅读 · 0 评论 -
[Leetcode] 1278. Palindrome Partitioning III (DFS / 动态规划)
1278.Palindrome Partitioning III (题目链接) Hard You are given a stringscontaining lowercase letters and an integerk. You need to : First, change some characters ofsto other lowercase English letters. Then dividesintoknon-empty disjoint substring...原创 2020-08-12 18:41:16 · 176 阅读 · 0 评论 -
[Leetcode] 132. Palindrome Partitioning II (动态规划)
132.Palindrome Partitioning II (动态规划) Hard 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: 1 Explanation: The ...原创 2020-08-12 17:05:29 · 96 阅读 · 0 评论 -
[LeeCode] 139. Word Break (递归+记忆数组 / dp)
139.Word Break Medium Given anon-emptystringsand a dictionarywordDictcontaining a list ofnon-emptywords, determine ifscan be segmented into a space-separated sequence of one or more dictionary words. Note: The same word in the dictionary may...原创 2020-07-12 03:28:33 · 214 阅读 · 0 评论 -
[LeeCode] 322. Coin Change (Python)
322.Coin Change Medium You are given coins of different denominations and a total amount of moneyamount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combi..原创 2020-07-10 09:07:54 · 231 阅读 · 0 评论 -
[LeeCode] 121. Best Time to Buy and Sell Stock (Python)
121.Best Time to Buy and Sell Stock Easy Say you have an array for which theithelement is the price of a given stock on dayi. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an a...原创 2020-07-10 08:28:46 · 184 阅读 · 0 评论 -
[LeeCode] 53. Maximum Subarray
53.Maximum Subarray Easy Given an integer arraynums, find the contiguous subarray(containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation:[4,-1,2,1] has the large...原创 2020-07-10 04:32:49 · 132 阅读 · 0 评论 -
[LeeCode] 5. Longest Palindromic Substring (Python)
5.Longest Palindromic Substring Medium 6919537Add to ListShare Given a strings, find the longest palindromic substring ins. You may assume that the maximum length ofsis 1000. Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid an...原创 2020-07-08 12:20:08 · 190 阅读 · 0 评论