Concept Flow - Buy and Sell Stocks All Variants
Start with prices array
Choose variant: single transaction / multiple / cooldown / fee
Initialize variables: buy_price, profit, cooldown, fee
Iterate over prices
Update buy_price or profit based on variant rules
Apply cooldown or fee if needed
End iteration
Return max profit
The flow starts with the prices array, selects the variant, iterates over prices updating buy price and profit according to rules, applies cooldown or fee if needed, and finally returns the maximum profit.
