随笔分类 -  动态规划

摘要:Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. 阅读全文
posted @ 2020-03-22 18:44 米开朗菠萝 阅读(120) 评论(0) 推荐(0)
摘要:A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The 阅读全文
posted @ 2020-03-22 17:53 米开朗菠萝 阅读(155) 评论(0) 推荐(0)
摘要:Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Example: Input: 2 Output: 91 Explanation: The answer shoul 阅读全文
posted @ 2020-03-22 11:16 米开朗菠萝 阅读(119) 评论(0) 推荐(0)
摘要:Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2 阅读全文
posted @ 2020-03-21 22:19 米开朗菠萝 阅读(149) 评论(0) 推荐(0)
摘要: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 O 阅读全文
posted @ 2020-03-21 21:34 米开朗菠萝 阅读(114) 评论(0) 推荐(0)
摘要: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 nee 阅读全文
posted @ 2020-03-21 21:07 米开朗菠萝 阅读(153) 评论(0) 推荐(0)
摘要:Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Example: Input: n = 10 Outpu 阅读全文
posted @ 2020-03-21 19:35 米开朗菠萝 阅读(115) 评论(0) 推荐(0)
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example: Input: 1 0 1 0 0 1 0 1 1 1 阅读全文
posted @ 2020-03-21 18:46 米开朗菠萝 阅读(128) 评论(0) 推荐(0)
摘要:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Example 1: Input: 阅读全文
posted @ 2020-03-19 21:36 米开朗菠萝 阅读(100) 评论(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 @ 2020-03-18 11:53 米开朗菠萝 阅读(121) 评论(0) 推荐(0)
摘要: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 @ 2020-03-18 10:41 米开朗菠萝 阅读(138) 评论(0) 推荐(0)
摘要:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Given nums = [-2, 0, 3, -5, 2, -1] sumR 阅读全文
posted @ 2020-03-17 15:37 米开朗菠萝 阅读(83) 评论(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 @ 2020-03-16 22:36 米开朗菠萝 阅读(118) 评论(0) 推荐(0)
摘要:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequ 阅读全文
posted @ 2020-03-16 20:47 米开朗菠萝 阅读(157) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Input: [10,9,2,5,3,7,101,18] Output: 4 Explanation: T 阅读全文
posted @ 2020-03-05 21:51 米开朗菠萝 阅读(130) 评论(0) 推荐(0)
摘要:Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitt 阅读全文
posted @ 2020-03-05 19:52 米开朗菠萝 阅读(138) 评论(0) 推荐(0)
摘要:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. 阅读全文
posted @ 2020-03-05 17:14 米开朗菠萝 阅读(126) 评论(0) 推荐(0)
摘要: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 right at any p 阅读全文
posted @ 2020-03-05 13:59 米开朗菠萝 阅读(117) 评论(0) 推荐(0)