what is space complkexity in this approach?
Help me out in this
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
use same array for keeping track of available positive numbers .
in that way u can solve ur problem without using any extra space
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.