09. Smallest Positive missing number
Last updated
Was this helpful?
Last updated
Was this helpful?
The problem can be found at the following link:
To find the missing number in an array of integers, I have used an unordered map
to store the presence of each element. Then, iterate through the array and mark each element as present in the map. After that, start from 1
and keep incrementing nin
until I find the first number that is not present in the map. Finally, return that missing number.
Time Complexity: O(n)
, where n
is the size of the input array. This is because we iterate through the array once to mark the presence of elements in the unordered map.
Auxiliary Space Complexity: O(n)
since we use an unordered map to store the presence of elements.
For discussions, questions, or doubts related to this solution, please visit our . We welcome your input and aim to foster a collaborative learning environment.
If you find this solution helpful, consider supporting us by giving a ⭐ star to the repository.