class Solution {
public:
int maxProfit(vector<int>& prices, int fee) {
if(prices.size() <= 0){
return 0;
}
int current_0;
int current_1;
int pre_0 = 0;
int pre_1 = -1e9;
for(int i =0 ; i<prices.size(); i++){
current_0 = max(pre_0, pre_1 + prices[i] - fee);
current_1 = max(pre_1, pre_0 - prices[i]);
pre_0 = current_0;
pre_1 = current_1;
}
return current_0;
}
};