122. Count the Nodes
Foundation1000 ms256 MBSolved by 0%
Build the list and print how many nodes it contains.
You must count by walking the list, not by printing n.
Constraints - `0 ≤ n ≤ 100000` - `-1000000 ≤ value ≤ 1000000`
Input
The first line contains an integer n, the number of nodes.
The second line contains n space-separated integers — the node values from head to tail.
The starter code builds the list for you; work on the nodes, not the array.
Output
Print one integer — how many nodes the list holds, counted by walking it.
Input5
1 2 3 4 5
Output5
Noteis an ordinary list
Input0
Output0
Noteis empty, so the walk must not start and the count stays at zero
Hint 1Approach
Hint 2Approach
Hint 3Pseudocode
Hint 4Full solution