- 博客(8)
- 收藏
- 关注
原创 leetcode - Largest Rectangle in Histogram
class Solution {public: int largestRectangleArea(vector<int>& heights) { int result = 0; stack<int> s; heights.push_back(0); for (int i = 0; i < heights.size(); ++i
2016-06-10 19:41:12 170
原创 leetcode - Best Time to Buy and Sell Stock IV
class Solution {public: int maxProfit(int k, vector<int>& prices) { if (k == 0 || prices.empty()) { return 0; } if (k > prices.size()/2) return help(prices);
2016-06-10 10:57:37 287
原创 leetcode - Best Time to Buy and Sell Stock III
class Solution {public: int maxProfit(vector<int>& prices) { if (prices.size() <= 1) return 0; vector<int> left(prices.size(), 0); vector<int> right(prices.size(), 0);
2016-06-07 23:42:33 166
原创 leetcode - Best Time to Buy and Sell Stock II
class Solution {public: int maxProfit(vector<int>& prices) { int result = 0; for (int i = 1; i < prices.size(); ++i) { if (prices[i] > prices[i-1]) { re
2016-06-07 22:55:07 175
原创 leetcode - Best Time to Buy and Sell Stock
class Solution {public: int maxProfit(vector<int>& prices) { if (prices.empty()) return 0; int min_price = prices[0]; int result = 0; for (int i = 1; i < prices.siz
2016-06-07 22:54:05 192
原创 leetcode - Jump Game II
class Solution {public: int jump(vector<int>& nums) { vector<int> f(nums.size(), nums.size()); f[0] = 0; for (int i = 0; i < nums.size(); ++i) { for (int j = i+
2016-06-07 21:43:21 149
原创 leetcode - Jump Game
class Solution {public: bool canJump(vector<int>& nums) { if (nums.empty()) return false; vector<bool> accessibility(nums.size(), false); accessibility[0] = true; f
2016-06-07 19:55:08 157
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人