Interview puzzles is the best way to check person's analytical skills. In investment banking job you need analytical skill to perform day to day job. It is not only applicable to traders , but some level of analytical skills is required by people who are developing these systems for understand business. Now a days it is become common practice to ask 1-2 puzzles during investment bank interview to check the candidate's analytical skills. The best way to clear this round is practice common puzzles and understand the logic to solve them.
1) Fibonacci in Java:
The input will be number n and the output should be sum for 0 to n. for example
for n =4 the result should be 0+1+2+3+4 = 10
2) String Reverse
The input String "abcde" should return "edcba".
3) Reversing a linked list in Java
Here is example of revering the linked list in java using recursive function:
4) Find the missing number in Java
You have an array of numbers from 1 to 100 (both inclusive). The size of the array is 100. The numbers are randomly added to the array, but there is one random empty slot in the array. What is the quickest way to find that slot as well as the number that should be put in the slot?
Try it for practice. please suggest the answer .
[Trick sum of n numbers is n*(n+1)/2]
5) Write a substring function in Java
String test= "AA BB CC BB BB CC BB";
String[]{"BB", "CC", "AA"}
Result shd be BB=4; CC=2 and AA=1
Since B occurred 4 times C did 2 times and A only 1 time.
This basic problem can be asked in different ways like, You have multiple words in new paper and find out the frequency of words in one page of news paper?
6) Reverse a String in Java
Reverse the String by java function without recursion and with recursion
7) Find one string inside another in Java
We can use String.indexOf( subString ) and it will return the first index of substring;
for Last Index : lastIndexOf(String str)
8) Algo for finding largest number in Array of Integer
Easy one, Check the integer one by one and find the largest number.
9) Java Runtime method invocation question:
Example : Tell the output of this
Answer is : 20 .
10) Suppose you have a large file with lots of words. How would you find the unique words and their count? What kind of data structure u will use? What will be the time complexity and space complexity?
We need to take care of two things counting the words and second duplicate. the best performance will be using hash function.
11) A train is one mile long. It travels at the rate of one mile a minute through a tunnel which is also one mile long. Can you say how long it will take for the train to pass completely through the tunnel?
Answer : 2 minutes
it will take two minutes if you count the time for it to completely pass through the tunnel. One minute to pass through the tunnel and another one minute to drag itself out of the tunnel completely so two minutes nice question though well logical.
12) Convert String = "98989" into an integer without using any library functions in java.
Give fastest way to do it and explain why your method is best.
// converting string to number using ascii code
13) Write a program to shuffle a deck of 52 cards and shuffle them equally to 4 players.