Loading...
Loading...
Loading...
A table has m slots numbered 0 to m - 1. Each key goes to slot key % m. If that slot is taken by a different key, try the next slot, wrapping from m - 1 to 0, until a free slot is found. A key already in the table is skipped. Print the table, with - for an empty slot.
Example 1
Input
8 3 11 19 6 14
Output
- - - 3 11 19 6 14
11 and 19 move forward from slot 3.
Example 2
Input
5 12 7 22 3
Output
3 - 12 7 22
Try the problem first. Open one hint at a time.
Start at key % m and move forward while the slot holds a different key.
Use (i + 1) % m so the search wraps around.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor