随笔分类 - 动态规划(DP)
摘要:题目:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 1...
阅读全文
摘要:题目:Write a program to find the nth super ugly number.Super ugly numbers are positive numbers whose all prime factors are in the given prime list prime...
阅读全文
摘要:题目:Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5...
阅读全文
摘要:题目:Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the ball...
阅读全文
摘要:题目:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may comp...
阅读全文
摘要:题目:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may comp...
阅读全文
摘要:题目:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may comp...
阅读全文
摘要:题目: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 transacti...
阅读全文
摘要:题目: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 (r...
阅读全文
摘要:题目: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...
阅读全文
摘要:该题来自leetcode,原题如下:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only cons...
阅读全文
摘要:斐波那契数列:1, 1, 2, 3, 5, 8, 13,...,即 f(n) = f(n-1) + f(n-2). 求第n个数的值。方法一:迭代 public static int iterativeFibonacci(int n) { //简单迭代 int a = 1, b =...
阅读全文
浙公网安备 33010602011771号