Maximum Subarray
题目描述: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,1,-5,4],the contiguous subarray [4,-1,2,1] has the largest sum = 6.LeetCode
Best Time to Buy and Sell Stock
题目描述: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 (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.
Example 1: Input: [7, 1, 5, 3, 6, 4], Output: 5
max. difference = 6-1 = 5 (not 7-1 = 6, as selling price needs to be larger than buying price)
Example 2: Input: [7, 6, 4, 3, 1], Output: 0
In this case, no transaction is done, i.e. max profit = 0.LeetCode
|
|
Best Time to Buy and Sell Stock II
题目描述: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 complete as many transactions as you like(ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).LeetCode
Best Time to Buy and Sell Stock III
题目描述: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 complete at most two transactions.
Note: You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
Triangle
问题描述:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.
Note: Bonus point if you are able to do this using only O(n) extra space, where n is the total number of rows in the triangle.LeetCode