Given the head of a singly linked list, return the 0-based position of the node holding the largest value. If several nodes share the largest value, return the position of the first one. Return -1 for an empty list.
Examples
Input: head = 3 -> 9 -> 2 -> 9
Output: 1
Input: head = (empty)
Output: -1
Constraints
0 <= number of nodes <= 10**4- Values can be negative
- Target: O(n) time, one pass
Goals
- Track both the best value and where it was seen
- Return the first position on ties