Implement Hash Map with with follow-up

Last updated: March 14, 2026

Quick Overview

Implement a hash map data structure that supports basic operations such as get and put in average O(1) time complexity. Your implementation should handle collisions using chaining or open addressing. The hash map should support the following operations: `put(key: K, value: V)` to insert or update a value by key, and `get(key: K)` to retrieve a value by key, returning null if the key does not exist.

Zillow
Coding & Algorithms
Software Engineer
Zillow
March 14, 2026
Software Engineer
Take-home Project
Coding & Algorithms
Medium

10

4

2,229 solved


Implement a hash map data structure that supports basic operations such as get and put in average O(1) time complexity. Your implementation should handle collisions using chaining or open addressing. The hash map should support the following operations: `put(key: K, value: V)` to insert or update a value by key, and `get(key: K)` to retrieve a value by key, returning null if the key does not exist.

Zillow uses this problem in the Take-home Project to evaluate your algorithmic thinking. They expect you to discuss multiple approaches, analyze trade-offs between them, and implement the optimal solution with clean, readable code.

What the Interviewer Expects
  • Recognize the underlying problem pattern (sliding window, two pointers, BFS/DFS, etc.)
  • Discuss multiple approaches and trade-offs before coding
  • Implement an optimal solution with clean, production-quality code
  • Handle all edge cases including boundary conditions and invalid input
  • Optimize both time and space complexity with clear justification
  • Test your solution systematically with well-chosen examples
Key Topics to Cover
Binary search and divide and conquer
Edge cases and input validation
Sorting and searching
Time and space complexity analysis
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Can you solve this iteratively instead of recursively (or vice versa)?
  • What happens if the input contains duplicates?
  • How would you test this solution thoroughly?
  • How would you parallelize this solution?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Problem Analysis

The problem requires us to implement a hash map that supports average O(1) time complexity for put and get operations. The key challenge is handling collisions, which can occur when multiple keys ...

Approach
  1. Initialize the Hash Map: Start with a fixed-size array (let's say of size 10) to hold the entries, and initialize each index with an empty list. This will allow for chaining.

  2. **Hash Functio...


Submit Your Answer
Markdown supported

Related Questions