I am having trouble understanding what I need to do. I hope someone can help me

I am not familiar with stock prices at all. I really do not understand what I am supposed to do. I am not looking for a solution to the problem. I am asking for someone to explain me better what am I being asked to create. Below is the assignment I am having trouble understanding.

Implement a method #stock_picker that takes in an array of stock prices, one for each hypothetical day. It should return a pair of days representing the best day to buy and the best day to sell. Days start at 0.

  => [1,4]  # for a profit of $15 - $3 == $12

Quick Tips:

  • You need to buy before you can sell
  • Pay attention to edge cases like when the lowest day is the last day or the highest day is the first day.


Each of the numbers in the array represent the stock price for a particular day. To find the best buy/sell combo, you would want to buy on the day with the lowest stock price, and sell on the day with the highest stock price (within the constraint of the day you buy coming before the day you sell). The answer in the example is [1, 4], because the combo of selling on Day # 2 (index of 1) and Day # 5 (index 4), gives you the highest possible profit.