Toast Inc Interview Question

HackerRank challenge: Typical problem of an integer array containing stock prices (each position in the array is 1 second) . You are asked to return the maximum profit assuming that you can only buy and sell once and the difference between buy and sell time must be at least five seconds long.