41. First Missing Positive | Top 100 Interview DSA Questions | Java Solution with time complexity

preview_player
Показать описание
This is the most frequently asked interview question.
And has been asked in many top product based companies like #amazon, #microsoft etc.

#amazon #microsoft
Рекомендации по теме
Комментарии
Автор

This is an amazing interview question with follow up question :
1. Find the kth missing positive in a sorted input.(Binary search)
2. Find the first Missing positive in an unsorted inputs (this question) great question to solve.
3. Find the missing number (from 0 to n)--->If we solve the above 2 question and come to this, this is very tricky but it's a simple math logic (n*(n+1)/2 -sum(input))

If we could give out thought process by mentioning trade offs for above 3 questions in an interview, no body can reject us!
Glad you came across this problem !

visase
Автор

One more condition have to chk I guess,
If(numsArray[value -1] > 0) then only update it to negetive...
If all no are distinct then not req this condition.

surojitsantra
Автор

Nice question and discussion around it.

Should we modify input array given to us ? If not, can we achieve O(n) TC and O(1) SC?

ketanlalcheta
Автор

Thanks for this kind of content Shreyansh
Could you please add leetcode link for every question you are solving?

imrohan
join shbcf.ru