dsa · medium
HashMap with Linear Probing
GreyOrangeHash MapDesign
GreyOrange live: hashing + **linear probing**. LinearHashMap(cap), put(k,v), get(k) missing → -1. Integer keys. Hash is k % cap. On collision, walk (i+1)%cap. No deletes in these tests (tombstones are the follow-up to discuss).
If the table is full, put of a *new* key is a no-op.
Fill in the LinearHashMap class. The starter already walks ops / args and calls your methods — leave the driver at the bottom as-is. Constructors contribute null; booleans print as true / false.
**Example**
`` LinearHashMap(4) → null put(1, 10) → null put(5, 20) → null get(1) → 10 get(5) → 20 get(9) → -1 ``
Constraints
cap >= 1, calls <= 200
Examples
Example 1
Input: ["LinearHashMap","put","put","get","get","get"] [[4],[1,10],[5,20],[1],[5],[9]] Expected: [null,null,null,10,20,-1]