currStreak
), the value of the current streak (currNum
), and the maximum streak (maxStreak
).result
to store the modes.currNum
, increment currStreak
.
b. If the node's value is different, compare currStreak
with maxStreak
and update result
accordingly. Reset currStreak
to 1 and currNum
to the node's value.
c. If currStreak
is greater than maxStreak
, update maxStreak
and reset result
to only contain the current node's value.
d. If currStreak
equals maxStreak
, append the current node's value to result
.result
as the list of modes.