Solution to Maximum Profits Problem

function maximumProfits(prices) {

const l = prices.length;

let max = 0;

for (let i = 0; i < l - 1; i++) {

     for (let j = i+1; j < l; j++){

        let k = prices[j] - prices[i];

       max = (max < k) ? k : max;

    }

  }

return max;

}