Sunday, October 2, 2011

Given a large collection of social numbers (e.g. 360Millions)

how to efficiently find a single missing number. You have a very large disk available for storing the number but just 2Mb of Ram

1 comment:

  1. actually only a couple of bytes are needed

    long long c = 0;
    for each number in the collection
    c += number

    return (1+360m)/2*360m - c

    ReplyDelete