I have written a O(n) solution with one pass of the list, but I’m not sure why perf cases are getting timed out.
Resubmitting fixed it.
Closing this topic as it has been solved by you yourself. Great job, keep working hard. if its not resolved feel free to un-mark the accepted solution to re-open the topic.