Cracking the Coding Interview: Fourth Edition (308 page e-book / PDF)
Delivered instantly as a PDF via email. For Software Engineers & SDETs
  • 150 programming interview questions and answers
  • 5 proven approaches to crack algorithm questions
  • 10 mistakes candidates make, and how to avoid them.
  • How to prepare for technical and behavioral questions without wasting your time!
"The BEST book for acing your interview. It helped me land my Microsoft job, and it was worth every penny!" - Ravi (Accepted at Microsoft, Amazon and Facebook) 30 Day Money Back Guarantee: Don't love the book? We'll give you your money back! More Info

Saturday, April 24, 2010

Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 2 numbers. Find the missing numbers.

3 comments:

  1. if the array is mutuable then try to put every number at its place.. and make it zero at the older place. go through the array and find out the indices with zero..

    OR

    find sum of the numbers and sum of the square of the numbers and apply the formulae

    sum of the numbers = n(n+1)/2
    sum of the square of the numbers = n(n+1)(2n+1)/6

    ReplyDelete
    Replies
    1. give me the relation connecting a+b ,a-b and a^2+b^2...
      thanks...

      Delete
    2. give me the relation between a+b,a-b and a^2+b^2..

      Delete