Given a list of daily stock prices, determine if it's possible to make the prices fluctuate by buying or selling stocks on adjacent days. The prices are said to fluctuate if every day's price is either higher or lower than the previous day's price, and the higher and lower prices alternate.
Explanation: Step-by-step: with input [1, 2, 3, 4, 5], we check if the prices are already in ascending order. Since they are, we return true because we can alternate between higher and lower prices by buying or selling stocks on adjacent days.
Explanation: Step-by-step: with input [5, 4, 3, 2, 1], we check if the prices are already in descending order. Since they are, we return true because we can alternate between higher and lower prices by buying or selling stocks on adjacent days.
Master coding challenges related to Arrays and solve the [Backup] Fluctuating Stock Prices problem optimally.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak