An interesting problem that someone had asked me -
You have a set of 300 pages that are numbered with you. The pages are in any random order. Suddenly the window opens and a single page flies out(don’t ask me why only a single page :P). Now the rule says that you can go thru the numbered pages exactly once and you can’t jot down the page numbers anywhere. How would you find the missing page number?
Solution: Let’s generalize the problem to ‘n’ pages. Find the sum of 1 to n. Call this x. Now as you can go thru the pages exactly once calculate the total of the page numbers as you go thru them. Call this total y. The missing page is obviously x – y;
No comments:
Post a Comment