Ideal Stock Trading Window

# Introduction In this challenge, we aim to address a stock trading issue. We must identify the optimal times to purchase and sell stocks from an array of stock prices to maximize profit. Our task is to compose a function named `maxProfit` that takes in a price array and yields the maximum attainable profit. Should it be impossible to obtain any profit, the function should return 0.

|60 : 00

Click the virtual machine below to start practicing