You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Writing programming interview questions hasn't made me rich yet ... so I might give up and start trading Apple stocks all day instead.
3
+
*
4
+
* First, I wanna know how much money I could have made yesterday if I'd been trading Apple stocks all day.
5
+
*
6
+
* So I grabbed Apple's stock prices from yesterday and put them in an array called stockPrices, where:
7
+
*
8
+
* The indices are the time (in minutes) past trade opening time, which was 9:30am local time.
9
+
* The values are the price (in US dollars) of one share of Apple stock at that time.
10
+
*
11
+
* So if the stock cost $500 at 10:30am, that means stockPrices[60] = 500.
12
+
*
13
+
* Write an efficient function that takes stockPrices and returns the best profit I could have made from one purchase and one sale of one share of Apple stock yesterday.
* Write a function that takes in an array of integers and returns an array of length 2 representing the largest range of numbers contained in that array. The first number in the output array should be the first number in the range while the second number should be the last number in the range. A range of numbers is defined as a set of numbers that come right after each other in the set of real integers. For instance, the output array [2, 6] represents the range {2, 3, 4, 5, 6}, which is a range of length 5. Note that numbers do not need to be ordered or adjacent in the array in order to form a range. Assume that there will only be one largest range.
0 commit comments