DEV Community

Cover image for 4 new challenges
Ilya Nevolin
Ilya Nevolin

Posted on

4 new challenges

I've added 4 new challenges to our ranked mode, one hard and three medium ones. The hard one is about finding word combinations in a 2D character matrix, it uses a depth-first search strategy. Two of the medium ones are about stock trading, below is a sample.

function maxProfit(prices) {
  let profit = 0;
  for(let i = 1; i < prices.length; i++) {
    if (prices[i] > prices[i -1]) {
      profit  = profit + prices[i] - prices[i - 1];
    }
  }
  return profit;
}

let arr = [7,5,3,2,1,4,5]
let A = maxProfit(arr);
// A = ?
Enter fullscreen mode Exit fullscreen mode

Top comments (0)