"Given a array of numbers representing the stock prices of a company in chronological order, write a function that calculates the maximum profit you could have made from buying and selling that stock once. You must buy before you can sell it"
Input: [7,1,5,3,6,4]
Output: 5
Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5.
Not 7-1 = 6, as selling price needs to be larger than buying price.
Also in JavaScript:
- open close children modal react
- check array for duplicate values javascript
- document write
- Bind Json file into a Datagridview in windows form using C#
- lodash remove undefined values from object
- Unable to resolve "react-navigation-stack" react native
- javascript recursion example
- js select option value when selected
- how to open new tab in vscode using keyboard
- javascript redirect new window
- "Given a array of numbers representing the stock prices of a company in chronological order, write a function that calculates the maximum profit you could have made from buying and selling that stock once. You must buy before you can sell it"
- react native reducer example
- js document onload
- redux saga fetch data using axios
- update react version
- how to print to screen in javascript
- js copy array
- foreach db mongodb
- how to creat emmet in react
- how to get a random element of an array javascript
- array in javascript
- How can I refresh a page with jQuery
- react 17
- javascript snumber two decimal places as string