Leetcode 1019: Finding the next greatest node — the Domino effect

Abrar Shariar
Console.log()
Published in
3 min readMay 15, 2020

--

Hack it yourself!

The Problem and example I/O:

The problem statement is to find the next greatest element in a linked List. So for the ith node we have to find the jth node, such that node value of j is greater than ith.

The catch here is that we have to find the most recent one. Let’s take an example:

[2,1,5]

output => [5,5,0]

--

--