Given a list of 4 billion integers, find an integer not on the list using 4 MB of memory. (the interview was in Java)
My solution is to use BitSet.
However, according to my calculations, there is not enough bits in 4 MB of memory! = C
4 megabytes = 4096 KB # times 8
4096 KB = ~ 4096000 bytes # multiply by 1000
4,096,000 Bytes = ~ 33,500,000 bits # multiply by 8
Thus, 33.5 million bits are two orders of magnitude less than a billion. Let one billion.
Or is this part of the question for dealing with this limitation?
java bit-manipulation bit
bezzoon
source share