Selected Google interview programs. #1 Given an array A of N positive integers and another number X. Determine whether or not there exist two elements in A whose sum is exactly X.
Input: 6 16 1 4 45 6 10 8 Output: Yes
#2 A magic number is defined as a number which can be expressed as a power of 5 or sum of unique powers of 5. First few magic numbers are 5, 25, 30(5 + 25), 125, 130(125 + 5), …. Write a function to find the nth Magic number.
Input: n = 2 Output: 25
Input: n = 5 Output: 130
#3 A number is called faithful if you can write it as the sum of distinct powers of 7. e.g., 2457 = 7 + 72 + 74 . If we order all the faithful numbers, we get the sequence 1 = 70, 7 = 71, 8 = 70 + 71, 49 = 72, 50 = 70 + 72 . . . and so on. Given some value of N, you have to find the N'th faithful number.