You are given the head of a linked list with n nodes. For each node, find the value of the next greater node, which is the first node following it with a strictly larger value. Return an array where each element is the value of the next greater node of the ith node. If there is no such node, use 0.
Click Run to execute sample tests.