Implement Hash Map with O(n) time

Last updated: January 24, 2026

Quick Overview

Implement a hash map that supports insert, delete, and lookup operations, all with an average time complexity of O(1). Your implementation should handle collisions using chaining or open addressing. The hash map should be able to store key-value pairs, and you should provide methods to add, remove, and retrieve values based on their keys.

Notion
Coding & Algorithms
Software Engineer
Notion
January 24, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

12

6

2,589 solved


Implement a hash map that supports insert, delete, and lookup operations, all with an average time complexity of O(1). Your implementation should handle collisions using chaining or open addressing. The hash map should be able to store key-value pairs, and you should provide methods to add, remove, and retrieve values based on their keys.

This coding problem is frequently asked during Technical Screen at Notion. The interviewer is testing your ability to translate a problem into clean, working code while discussing time and space complexity. Notion expects candidates to write production-quality code, not just solve the puzzle.

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
Sorting and searching
Tree structures and recursion
Time and space complexity analysis
Edge cases and input validation
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
  • What is the worst-case input for your solution?
  • What if the input doesn't fit in memory?
  • How would you parallelize this solution?
  • How would you test this solution thoroughly?
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 implementing a hash map that supports O(1) time complexity for insert, delete, and lookup operations. A hash map is typically implemented using a fixed-size array and a hash funct...

Approach
  1. Choose a Size for the Hash Map: We will initialize an array of a certain size (e.g., 10) for our hash map. This size can be adjusted based on expected load.
  2. Hash Function: Implement a ...

Submit Your Answer
Markdown supported

Related Questions