Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions DynamicProgramming/BestTimeToBuyAndSellStocks-II.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ int Solution::maxProfit(const vector<int> &A) {
// Do not print the output, instead return values as specified
// Still have a doubt. Checkout www.interviewbit.com/pages/sample_codes/ for more details

vector<int> temp(A.size(), 0);
// vector<int> temp(A.size(), 0);

int buy = A[0], flag = 0, i = 1, max_sell = INT_MIN;
// int buy = A[0], flag = 0, i = 1, max_sell = INT_MIN;
if(A.size() == 0 || A.size() == 1) return 0;
int sol = 0;
while(i < A.size()){
int diff = A[i] - A[i-1];
Expand Down