advancedDSA & Coding364 of 436

Coding: find the smallest missing positive integer (>0) in an unsorted array

Tests whether you achieve O(n) time and O(1) extra space by using the array itself as a hash table -- placing each value v at index v-1 via in-place swaps, then scanning for the first index that doesn't hold its expected value.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

← Back to all Core Java questions