Next Greater Node In Linked List
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given the head of a singly linked list with n nodes. For every node, find the value of the **first node after it** whose value is **strictly greater** than its own.
Return an integer array answer of length n where answer[i] is that next greater value for the i-th node (0-indexed from the head). If no later node has a strictly greater value, answer[i] is 0.
Equal values do not count as greater. Aim for O(n) time.
Examples
Constraints
- The number of nodes `n` satisfies `1 <= n <= 10^4`.
- `1 <= Node.val <= 10^9`
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.