-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
Bug Report for https://neetcode.io/problems/buy-and-sell-crypto
Hello! I noticed that the following solution works correctly on all test cases:
class Solution {
public:
int maxProfit(vector<int>& prices) {
int result = 0;
int l = 0, r = 1;
while (r < prices.size()) {
result = max(result, prices[r] - prices[l]);
if (prices[l] > prices[r]) {
l = r;
}
r++;
}
}
};
Please add test case [3, 4, 1]
Metadata
Metadata
Assignees
Labels
No labels