Help me out in this


what is space complkexity in this approach?

@aman212yadav are u there ?

hello @shivammishra20121999

space complexity is O(N) …because in worst case u will be storing all elements

@aman212yadav https://leetcode.com/problems/first-missing-positive/
but above solution is accepted why irrespective its sc is o(n)?

O(N) space is acceptable.
that O(1) space is follow up constraint ie they want u to come up with O(1) space approach if u have solved it using o(n) space

@aman212yadav i tried a lot you know any logic whose sc is o(1)?

use same array for keeping track of available positive numbers .
in that way u can solve ur problem without using any extra space

@aman212yadav let me try

refer this for better clarity ->link

@aman212yadav thks bro i am struggling for doing it in o(1) space for last two hrs?
thks

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.