Back to course home
0% completed
Vote For New Content
I think the space complexity is O(n) not O(k) because at most you would store n ...
Russell Rogers
Mar 5, 2022
I think the space complexity is O(n) not O(k) because at most you would store n extra numbers in the situation where everything inside the array is either n.
0
0
Comments
Comments
Design Gurus4 years ago
We never insert more than 'K' numbers in the 'extraNumebrs' array.
If you look closly at the first 'for' loop, we insert numbers to both the arrays at the same:
missingNumbers.add(i + 1); extraNumbers.add(nums[i]);
Since 'missingNumebrs' can't have more than 'K' numb...
P
PENG SHI4 years ago
by extending nums with K 0s, just find first K missing will be enough
On this page