"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"
JavaScript
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:
- Title
- a simple javascript calculator
- Category
- JavaScript
- Title
- angular http
- Category
- JavaScript
- Title
- async await promise all javascript
- Category
- JavaScript
- Title
- express how to access ajax post data
- Category
- JavaScript
- Title
- how to get the index of an array in javascript
- Category
- JavaScript
- Title
- how to open bash_profile
- Category
- JavaScript
- Title
- how to convert time to am pm in javascript
- Category
- JavaScript
- Title
- get date one week from now javascript
- Category
- JavaScript
- Title
- fetch api react
- Category
- JavaScript
- Title
- how to access child img src in jquery
- Category
- JavaScript
- Title
- classList has class
- Category
- JavaScript
- Title
- edje js not pre compile for node 12 version
- Category
- JavaScript
- Title
- ajax request qml
- Category
- JavaScript
- Title
- create a customer in stripe node.js
- Category
- JavaScript
- Title
- clear the console while in strict mode
- Category
- JavaScript
- Title
- drupal 8 node has field
- Category
- JavaScript
- Title
- angular run with proxy
- Category
- JavaScript
- Title
- .join javascript
- Category
- JavaScript
- Title
- Error: Can't resolve 'fs' webpack
- Category
- JavaScript
- Title
- deny ready jquery
- Category
- JavaScript
- Title
- define a route with path paramters in nodejs
- Category
- JavaScript
- Title
- audio get current time
- Category
- JavaScript
- Title
- how to use js console log
- Category
- JavaScript
- Title
- change js to json
- Category
- JavaScript
- Title
- how to update node.js on linux
- Category
- JavaScript
- Title
- express fingerprint
- Category
- JavaScript
- Title
- async await javascript
- Category
- JavaScript
- Title
- get all a tags javascript
- Category
- JavaScript
- Title
- document delete element
- Category
- JavaScript
- Title
- get unique id angular
- Category
- JavaScript
- Title
- day to week
- Category
- JavaScript
- Title
- change text of element js
- Category
- JavaScript
- Title
- how to display image in html from json object
- Category
- JavaScript
- Title
- gitignore for angular
- Category
- JavaScript
- Title
- elseif javascript
- Category
- JavaScript
- Title
- how to get textedit on mac without download
- Category
- JavaScript
- Title
- get value of checked radio button jquery
- Category
- JavaScript
- Title
- how to return the number of nodes in a linked list
- Category
- JavaScript
- Title
- hide urls in .env in react app
- Category
- JavaScript
- Title
- find last element with class jquery
- Category
- JavaScript
- Title
- angular 8 to 9
- Category
- JavaScript
- Title
- Angular watching for changes in $http.pendingRequests from directive
- Category
- JavaScript
- Title
- how to program an array in js
- Category
- JavaScript
- Title
- git empty commit
- Category
- JavaScript
- Title
- event target javascript
- Category
- JavaScript
- Title
- how to move up in terminal
- Category
- JavaScript
- Title
- is sublime text a good editor
- Category
- JavaScript
- Title
- get value of all checked boxes jquery
- Category
- JavaScript
- Title
- javascript array pop
- Category
- JavaScript
- Title
- find leap year javascript
- Category
- JavaScript
- Title
- cascading dropdown for forms react
- Category
- JavaScript
- Title
- html decode javascript
- Category
- JavaScript
- Title
- google apps script lock service
- Category
- JavaScript
- Title
- enable disable click on div jquery
- Category
- JavaScript
- Title
- how to take create array using jquery
- Category
- JavaScript
- Title
- firestore update array
- Category
- JavaScript
- Title
- convert jquery to string
- Category
- JavaScript
- Title
- hit enter button lick in js
- Category
- JavaScript
- Title
- add multiple images inside the DOM js
- Category
- JavaScript
- Title
- check if date equal js
- Category
- JavaScript
- Title
- javascript check empty object
- Category
- JavaScript
- Title
- check if a key exists in an object javascript
- Category
- JavaScript
- Title
- javascript add row to table
- Category
- JavaScript
- Title
- how to send enter event to input field jquery
- Category
- JavaScript
- Title
- add table row jQuery
- Category
- JavaScript
- Title
- function to create an element javascript
- Category
- JavaScript
- Title
- iterate object js
- Category
- JavaScript
- Title
- angularjs left xx characters
- Category
- JavaScript
- Title
- clear input field value javascript
- Category
- JavaScript
- Title
- delete all childs in node
- Category
- JavaScript
- Title
- how to manage a db connection in javascript
- Category
- JavaScript
- Title
- convert array object to string javascript
- Category
- JavaScript
- Title
- closure javascript
- Category
- JavaScript
- Title
- .pop js
- Category
- JavaScript
- Title
- javascript assignment operator if undefined
- Category
- JavaScript
- Title
- javascrip check if string contains substring
- Category
- JavaScript
- Title
- how to pretty formatjson value on terminal ruby
- Category
- JavaScript
- Title
- how to use a fixed time zone in nodejs
- Category
- JavaScript
- Title
- dynsmic calss in react add
- Category
- JavaScript
- Title
- go to anchor jquery
- Category
- JavaScript
- Title
- if (req.url === "/script.js")
- Category
- JavaScript
- Title
- how reliable is js hasownproperty
- Category
- JavaScript
- Title
- checking object is empty in JS
- Category
- JavaScript
- Title
- javascript class click event
- Category
- JavaScript
- Title
- how to make a javascript game
- Category
- JavaScript
- Title
- email regex javascript
- Category
- JavaScript
- Title
- javascript change query parameter without reloading
- Category
- JavaScript
- Title
- hooks in react
- Category
- JavaScript
- Title
- javascript canvas beziercurveto
- Category
- JavaScript
- Title
- define all jsdoc typedef in a seperate file
- Category
- JavaScript
- Title
- isogram
- Category
- JavaScript
- Title
- empty array js
- Category
- JavaScript
- Title
- check row empty array javascript
- Category
- JavaScript
- Title
- (function (g, d, a) {})(window, document, jQuery);
- Category
- JavaScript
- Title
- convert json to 2d array
- Category
- JavaScript
- Title
- 404 json laravel
- Category
- JavaScript
- Title
- get number right of the dot length javascript
- Category
- JavaScript
- Title
- how to set random dice image with js
- Category
- JavaScript
- Title
- how to stringify json in js
- Category
- JavaScript
- Title
- class javascript
- Category
- JavaScript