Amazon Technical Paper
Amazon Technical Paper
1. Given a dictionary with limited words. Check if the string given to you is a composite of two
words which are already present in the dictionary.
2. Is {a, n, d} a palindrome ? If you are given a random string, is it a palindrome or not?
3. What is the function of the 'finally' block in Java? Under what conditions does the finally block
not get executed, if this is possible?
4. Given a binary search tree. Traverse only the left sub-tree.
5. Generate the following pattern when x is given upto Nth terms
For ex:
OUTPUT:
12
1112
3112
132112
For ex:
Input: 12
Output: 16
16. Write a function which takes as parameters one regular expression(only ? and * are the
special characters) and a string and returns whether the string matched the regular
expression.
17. Given n red balls and m blue balls and some containers, how would you distribute those
balls among the containers such that the probability of picking a red ball is maximized,
assuming that the user randomly chooses a container and then randomly picks a ball from
that.
18. Find the second largest element in an array with minimum no of comparisons and give the
minimum no of comparisons needed on an array of size N to do the same.
19. Given an array of size n, containing every element from 1 to n+1, except one. Find the
missing element.
20. How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do
the same
21. Given an array of size n. It contains numbers in the range 1 to n. Each number is present at
least once except for 1 number. Find the missing number.
22. Explain polymorphism. Provide an example.
23. Given an array all of whose elements are positive numbers, find the maximum sum of a
subsequence with the constraint that no 2 numbers in the sequence should be adjacent in
the array. So 3 2 7 10 should return 13 (sum of 3 and 10) or 3 2 5 10 7 should return 15
(sum of 3, 5 and 7)
24. You are given some denominations of coins in an array (int denom[])and infinite supply of all
of them. Given an amount (int amount), find the minimum number of coins required to get the
exact amount. What is the method called?