Easy · Linked Lists
Find node
Given the head of a singly linked list and a value val, return the first node whose value equals val (the node itself, so the list reads on from it), or null if no node matches.
Examples
Example 1
[3,1,4,1,5] find 4Output: node[2] = 4
Example 2
[2,7,8] find 9Output: nil
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.