140. Count Occurrences
Foundation1000 ms256 MBSolved by 0%
Build the list, read a value k, and print how many nodes hold that value.
Constraints - `0 ≤ n ≤ 100000` - `-1000000 ≤ value, k ≤ 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.
The third line contains an integer k.
Output
Print one integer — how many nodes hold the value k.
Input6
1 2 2 3 2 4
2
Output3
Notehas the value three times
Input4
1 2 3 4
9
Output0
Notelooks for a value that is absent
Hint 1Approach
Hint 2Approach
Hint 3Pseudocode
Hint 4Full solution