随笔分类 -  DP

摘要:You are given weights and values of N items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack. Note that we 阅读全文 »
posted @ 2021-04-20 23:56 Veritas_des_Liberty 阅读(65) 评论(0) 推荐(0) 编辑
摘要:给你一个字符串 s ,每一次操作你都可以在字符串的任意位置插入任意字符。 请你返回让 s 成为回文串的 最少操作次数 。 「回文串」是正读和反读都相同的字符串。 示例 1: 输入:s = "zzazz"输出:0解释:字符串 "zzazz" 已经是回文串了,所以不需要做任何插入操作。示例 2: 输入: 阅读全文 »
posted @ 2021-04-16 21:30 Veritas_des_Liberty 阅读(160) 评论(0) 推荐(0) 编辑
摘要:X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X. Each digit must be rotate 阅读全文 »
posted @ 2019-04-26 22:10 Veritas_des_Liberty 阅读(231) 评论(0) 推荐(0) 编辑
摘要:Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where in each step you can delete one cha 阅读全文 »
posted @ 2019-04-23 12:06 Veritas_des_Liberty 阅读(191) 评论(0) 推荐(0) 编辑
摘要:A string of '0's and '1's is monotone increasing if it consists of some number of '0's (possibly 0), followed by some number of '1's (also possibly 0. 阅读全文 »
posted @ 2019-04-12 21:19 Veritas_des_Liberty 阅读(301) 评论(0) 推荐(0) 编辑
摘要:There are N piles of stones arranged in a row. The i-th pile has stones[i] stones. A move consists of merging exactly K consecutive piles into one pil 阅读全文 »
posted @ 2019-03-28 19:43 Veritas_des_Liberty 阅读(271) 评论(0) 推荐(0) 编辑
摘要:A subarray A[i], A[i+1], ..., A[j] of A is said to be turbulent if and only if: For i <= k < j, A[k] > A[k+1] when k is odd, and A[k] < A[k+1] when k  阅读全文 »
posted @ 2019-03-28 17:23 Veritas_des_Liberty 阅读(361) 评论(0) 推荐(0) 编辑
摘要:You are given an integer array A. From some starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called od 阅读全文 »
posted @ 2019-03-28 17:04 Veritas_des_Liberty 阅读(284) 评论(0) 推荐(0) 编辑
摘要:Given a string S, count the number of distinct, non-empty subsequences of S . Since the result may be large, return the answer modulo 10^9 + 7. Exampl 阅读全文 »
posted @ 2019-03-27 22:34 Veritas_des_Liberty 阅读(270) 评论(0) 推荐(0) 编辑
摘要:A chess knight can move as indicated in the chess diagram below: . This time, we place our chess knight on any numbered key of a phone pad (indicated 阅读全文 »
posted @ 2019-03-27 21:51 Veritas_des_Liberty 阅读(339) 评论(0) 推荐(0) 编辑
摘要:Given a square array of integers A, we want the minimum sum of a falling path through A. A falling path starts at any element in the first row, and ch 阅读全文 »
posted @ 2019-03-26 18:27 Veritas_des_Liberty 阅读(229) 评论(0) 推荐(0) 编辑
摘要:Your music player contains N different songs and she wants to listen to L (not necessarily different) songs during your trip. You create a playlist so 阅读全文 »
posted @ 2019-03-26 17:52 Veritas_des_Liberty 阅读(228) 评论(0) 推荐(0) 编辑
摘要:We have a sorted set of digits D, a non-empty subset of {'1','2','3','4','5','6','7','8','9'}. (Note that '0' is not included.) Now, we write numbers 阅读全文 »
posted @ 2019-03-25 10:21 Veritas_des_Liberty 阅读(232) 评论(0) 推荐(0) 编辑
摘要:We have an array A of non-negative integers. For every (contiguous) subarray B = [A[i], A[i+1], ..., A[j]] (with i <= j), we take the bitwise OR of al 阅读全文 »
posted @ 2019-03-25 09:19 Veritas_des_Liberty 阅读(259) 评论(0) 推荐(0) 编辑
摘要:You are given K eggs, and you have access to a building with N floors from 1 to N. Each egg is identical in function, and if an egg breaks, you cannot 阅读全文 »
posted @ 2019-03-24 16:29 Veritas_des_Liberty 阅读(244) 评论(0) 推荐(0) 编辑
摘要:There are G people in a gang, and a list of various crimes they could commit. The i-th crime generates a profit[i] and requires group[i] gang members 阅读全文 »
posted @ 2019-03-23 16:17 Veritas_des_Liberty 阅读(298) 评论(0) 推荐(0) 编辑
摘要:A sequence X_1, X_2, ..., X_n is fibonacci-like if: n >= 3 X_i + X_{i+1} = X_{i+2} for all i + 2 <= n Given a strictly increasing array A of positive 阅读全文 »
posted @ 2019-03-23 12:45 Veritas_des_Liberty 阅读(258) 评论(0) 推荐(0) 编辑
摘要:There are N dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to t 阅读全文 »
posted @ 2019-03-22 21:04 Veritas_des_Liberty 阅读(323) 评论(0) 推荐(0) 编辑
摘要:We partition a row of numbers A into at most K adjacent (non-empty) groups, then our score is the sum of the average of each group. What is the larges 阅读全文 »
posted @ 2019-03-21 17:52 Veritas_des_Liberty 阅读(279) 评论(0) 推荐(0) 编辑
摘要: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 the s 阅读全文 »
posted @ 2019-03-19 21:47 Veritas_des_Liberty 阅读(408) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示