Loading...
Loading...
Loading...
Build a linear probing table with m slots as in the previous problem (key goes to key % m, then the next slot until a free one, wrapping). Then for each query, count the slots examined: start at query % m, count each slot looked at, and stop when the query is found or an empty slot is met.
Example 1
Input
8 3 11 19 6 14 3 19 14 27 1
Output
1 3 2 6 1
Key 27 passes five full slots before the empty slot 0.
Example 2
Input
5 1 2 1 2 3
Output
1 1 1
Try the problem first. Open one hint at a time.
Build the table first. Reuse the same probing loop for the queries.
Count a slot as examined when you look at it, including the final one.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor