Leetcode 121 Best Time to Buy and Sell Stock
来源:互联网 发布:详解进化论知乎 编辑:程序博客网 时间:2024/06/06 01:23
Leetcode 121 Best Time to Buy and Sell Stock
#include <vector>#include <math.h>using namespace std;class Solution {public: int maxProfit(vector<int>& prices)//brute force time limit exceeded { if(prices.empty()) return 0; int maxprofit = 0; int size = prices.size(); int buyPrice = prices[0]; for(int i = 1;i < size;i ++) { buyPrice = min(buyPrice,prices[i]); maxprofit = max(maxprofit,prices[i] - buyPrice); } return maxprofit; }};
阅读全文
0 0
- LeetCode 121: Best Time to Buy and Sell Stock
- LeetCode(121)Best Time to Buy and Sell Stock
- LeetCode 121 Best Time to Buy and Sell Stock
- LeetCode: Best Time to Buy and Sell Stock [121]
- LeetCode 121 Best Time to Buy and Sell Stock
- [leetcode 121] Best Time to Buy and Sell Stock
- Leetcode NO.121 Best Time to Buy and Sell Stock
- LeetCode 121 Best Time to Buy and Sell Stock
- LeetCode(121) Best Time to Buy and Sell Stock (Java)
- leetcode-121 Best Time to Buy and Sell Stock
- leetcode || 121、Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock - LeetCode 121
- leetcode#121 Best Time to Buy and Sell Stock
- Leetcode 121 Best Time to Buy and Sell Stock
- Leetcode #121 Best Time to Buy and Sell Stock
- leetcode 121: Best Time to Buy and Sell Stock
- leetcode: (121) Best Time to Buy and Sell Stock
- 121 Best Time to Buy and Sell Stock [Leetcode]
- web移动端meta标签小结
- Opencv学习笔记_计算机视觉是什么?Opencv的起源
- ES6--const
- Java内存模式简介
- 375. Guess Number Higher or Lower II
- Leetcode 121 Best Time to Buy and Sell Stock
- 【java】 Dubbo访问有时候访问到,有时候访问不到问题
- Test Mission: Definition, Components and Application
- 修改项目的JDK和WEB版本
- Leetcode 389 Find the Difference
- java练习题2
- 卷积和傅立叶变换
- Leetcode 412 Fizz Buzz
- 正则表达式基本用法