随笔分类 -  动态规划

摘要:Given a string s and a string t, check if s is subsequence of t. You may assume that there is only lower case English letters in both s and t. t is po 阅读全文
posted @ 2018-02-10 16:35 A-Little-Nut 阅读(136) 评论(0) 推荐(0)
摘要:In LeetCode Store, there are some kinds of items to sell. Each item has a price. However, there are some special offers, and a special offer consists 阅读全文
posted @ 2018-02-10 16:34 A-Little-Nut 阅读(202) 评论(0) 推荐(0)
摘要:Initially on a notepad only one character 'A' is present. You can perform two operations on this notepad for each step: Copy All : You can copy all th 阅读全文
posted @ 2018-02-10 16:33 A-Little-Nut 阅读(257) 评论(0) 推荐(0)
摘要:Given an array of scores that are non negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and t 阅读全文
posted @ 2018-02-10 16:32 A-Little-Nut 阅读(99) 评论(0) 推荐(0)
摘要:Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum pro 阅读全文
posted @ 2018-02-10 16:31 A-Little-Nut 阅读(106) 评论(0) 推荐(0)
摘要:Given a non negative integer n, count all numbers with unique digits, x, where 0 ≤ x Given n = 2, return 91. (The answer should be the total numbers i 阅读全文
posted @ 2018-02-10 16:31 A-Little-Nut 阅读(119) 评论(0) 推荐(0)
摘要: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 follow an 阅读全文
posted @ 2018-02-10 16:30 A-Little-Nut 阅读(131) 评论(0) 推荐(0)
摘要:Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal. Example 1: Input: s1 = "sea", s2 = "eat" Output: 阅读全文
posted @ 2018-02-10 16:29 A-Little-Nut 阅读(290) 评论(0) 推荐(0)
摘要:A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the 阅读全文
posted @ 2018-02-10 16:27 A-Little-Nut 阅读(156) 评论(0) 推荐(0)
摘要:Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are c 阅读全文
posted @ 2018-02-10 16:01 A-Little-Nut 阅读(120) 评论(0) 推荐(0)
摘要:本篇文章作为个人的背包问题学习资料,来自转载 "dd大牛的《背包九讲》" . P01: 01背包问题 题目 有N件物品和一个容量为V的背包。第i件物品的费用是c[i],价值是w[i]。求解将哪些物品装入背包可使这些物品的费用总和不超过背包容量,且价值总和最大。 基本思路 这是最基础的背包问题,特点是 阅读全文
posted @ 2018-01-28 21:23 A-Little-Nut 阅读(319) 评论(0) 推荐(0)
摘要:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and r 阅读全文
posted @ 2018-01-21 10:07 A-Little-Nut 阅读(172) 评论(0) 推荐(0)
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo 阅读全文
posted @ 2018-01-21 09:04 A-Little-Nut 阅读(155) 评论(0) 推荐(0)
摘要:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Note: 1: You may assume that the array 阅读全文
posted @ 2018-01-20 21:37 A-Little-Nut 阅读(143) 评论(0) 推荐(0)
摘要:On a staircase, the i th step has some non negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. Y 阅读全文
posted @ 2018-01-20 21:15 A-Little-Nut 阅读(181) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文
posted @ 2018-01-20 20:50 A-Little-Nut 阅读(375) 评论(0) 推荐(0)
摘要:You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl 阅读全文
posted @ 2018-01-20 20:44 A-Little-Nut 阅读(157) 评论(0) 推荐(0)
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [ 2,1, 3,4, 1,2, 阅读全文
posted @ 2018-01-20 20:36 A-Little-Nut 阅读(178) 评论(0) 推荐(0)