Skip to content
Tagged articles

Pigeonhole Principle

1 articles · Page 1 of 1
Rain's Path to Java Mastery
Rain's Path to Java Mastery
Nov 7, 2026 · Interview Experience

In-Place Hashing Cracks LeetCode 41: O(n) Time, O(1) Space

This article explains how to solve LeetCode 41 First Missing Positive using in-place hashing, leveraging the pigeonhole principle to bound the answer, and provides two Java implementations—cyclic sort and sign marking—with detailed walkthroughs, pitfall analysis, and interview follow-up questions.

Cyclic SortFirst Missing PositiveIn-Place Hashing
0 likes · 20 min read
In-Place Hashing Cracks LeetCode 41: O(n) Time, O(1) Space