|
|
|
|
|
by TacticalCoder
354 days ago
|
|
> "You are given an array A of n - 1 integers" It's an array of integers so it fits in memory (otherwise it wouldn't be called an array). As it fits in memory, n cannot be that big. I'd still ask for more requirements, TopCoder problem style: I want to know how big n can be that the array fits in memory. I didn't know that XOR trick. My solution would be a bit arrays with n bits and two for loops: one to light each bit corresponding to a number and one for loop to find the missing number. And if my bit array doesn't fit in memory, then neither does the array from the problem (and certainly not the HashSet etc.). |
|
That makes the problem harder which makes it more interesting, a lot of the solutions wouldn't work anymore (this isn't necessarily a good interview question though)