HashingEvidence Contributing

Hashmap Existence / Complement Lookup

Use a hashmap or set purely to answer 'have I seen this before' or 'does the complement exist', not to count occurrences.

Practice Problems: 6
Difficulty: 3 Easy·3 Medium·0 Hard

Algorithmic Intuition & Recognition

The Hashmap Existence / Complement Lookup technique is applied when tackling problems characterized by specific invariants in the problem state or constraints:

  • Core Strategy: Use a hashmap or set purely to answer 'have I seen this before' or 'does the complement exist', not to count occurrences.
  • When to use: Look for opportunities where repeated re-computation can be replaced by maintaining monotonic properties, state windows, or relational pointers.
  • Interview Signal: Demonstrating this pattern shows mastery of Hashing foundations, reducing worst-case algorithmic complexity.

Canonical Practice Problems

6 problems

Curated Sheets Containing This Pattern

Related Algorithmic Patterns