← Accolite questions

Maximum Profit by Buying and Selling a Share at Most Twice

Filed under Accolite · Also reported at Visa

Given an array of price numbers where prices[i] is the price of a given stock on the i-th day, find the maximum profit you can achieve. You may complete at most two transactions.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Accolite questions

Collected from public candidate posts and coding forums. Updated Nov 2026.