This was a question that was asked to my friend in a Google interview a while back. He was unable to come up with a solution but ended up bagging the job anyway. Here's the question
You have been given 300 digits comprising of 100 ones, 100 twos, and 100 threes, now come up with an algorithm that will determine all such numbers which are a perfect square
I tried this for a while but am stumped. Any thoughts on how to go about this?
300 is a number that is not a perfect square. This indicates that it does not have a natural number as its square root. Also, its square root cannot be expressed as a fraction of the form p/q which tells us that the square root of 300 is an irrational number.
They are 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900 and 961.
121 , 144, 169, 196 - There are four perfect squares between 100 and 200.
Is 1000 a perfect square? We know, 1000 = 2 × 2 × 2 × 5 × 5 × 5.
printf ("{}\n");
The set in question is empty (the sum of the digits is divisible by 3 but not by 9).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With