Saturday, 18 June 2016

Interview Questions with Solution

Interview Questions with Solution

Software Engineer Interview

 
1. There are two sorted arrays . Find the median of array obtained by Merging these two arrays.
http://www.geeksforgeeks.org/median-of-two-sorted-arrays/

2. Transpose of a matrix
http://www.geeksforgeeks.org/inplace-m-x-n-size-matrix-transpose/

3. Garbage Collection in Java. Mark & Sweep Algorithm
http://javarevisited.blogspot.com/2011/04/garbage-collection-in-java.html/
 
Alternate:
http://www.geeksforgeeks.org/mark-and-sweep-garbage-collection-algorithm/



4. Fill 4 Lt using 5 Lt and 3 Lt Jars.

5. Given an array that contains both positive and negative integers, find the product of the maximum product subarray
http://www.geeksforgeeks.org/maximum-product-subarray/

6. Rotate a Matrix clockwise by 90 degree.

7. Puzzle : There are n Prisoners standing in a line with increasing height such that each prisoner can see the hat color of prisoners standing ahead of him but he cannot see his own hat color. Hats are of only two color , Red or Blue. Now each prisoner has to say his hat color. If he is right, he lives otherwise the Jailer will shoot him. Find the strategy to save maximum number of prisoners.

8. There is a binary stream coming . You need to print true or false based on the fact whether the number formed is divisible by 5 or not.
https://www.careercup.com/question?id=11903257

9. Print all subset of a Set .
http://www.geeksforgeeks.org/power-set/

10 Given a string of any length. print all possible combinations of string length k
http://www.geeksforgeeks.org/print-all-combinations-of-given-length/

11 Given a matrix, print in spiral order.
http://www.geeksforgeeks.org/print-a-given-matrix-in-spiral-form/

12 Verify whether given tree is BST or not.
http://www.geeksforgeeks.org/a-program-to-check-if-a-binary-tree-is-bst-or-not/

13 Various approached to implement dictionary

14 Various approaches and complexities for array rotation problem.

15 Infinite streams of number, find top k numbers.
http://www.geeksforgeeks.org/kth-largest-element-in-a-stream/

16 You have 9 balls, equally big, equally heavy - except for one, which is a little heavier.
How would you identify the heavier ball if you could use a pair of balance scales only twice?
http://www.mathsisfun.com/puzzles/weighing-9-balls-solution.html

17 Detect & return the intersection point of 2 linked list.
http://www.geeksforgeeks.org/write-a-function-to-get-the-intersection-point-of-two-linked-lists/

18 Multiple 2 numbers using bitwise operator.
http://www.geekinterview.com/question_details/33640

19 Given a number, find the next highest number formed using the same digits.
http://www.geeksforgeeks.org/find-next-greater-number-set-digits/

20 Clone a linked list given 2 pointers, next & arbit.

21 Given inorder and postorder traversal make the actual tree.

22 Find the longest distance between two nodes in a tree.

23 Print right view of a binary tree

24 Design a DS which does push, pop and min in O(1)

25 Find the maximum sum subarray from a given array.Array can have negative elements too.We have to print initial and final position of the subarray. Hint: Kadane’s Algorithm

26 You’ve got someone working for you for seven days and a gold bar to pay him. The gold bar is segmented into seven connected pieces. You must give them a piece of gold at the end of every day. What and where are the fewest number of cuts to the bar of gold that will allow you to pay him 1/7th each day?
http://www.crazyforcode.com/gold-bar-cuts-puzzle/

27 Write the code to find a given word in the given string

28 You are about to leave for holiday, but you forgot socks! You race back to your room, but all the lights are off, so you can't see the color of the socks.
Never mind, because you remember that in your drawer there are ten pairs of white socks, ten pairs of black socks, and eleven pairs of blue socks, but they are all mixed up.
How many of your socks do you need to take before you can be sure to have at least one matching pair?
http://www.mathsisfun.com/puzzles/matching-socks-solution.html

29 Consider a regular telephone dial up. It has generally three alphabets for each digit. For example, ABC for 2 and so on.
Given a number. Print all the possible strings by taking one alphabet corresponding to each digit in number.
Input: 254
Output: AKH, AJG etc.

30 Write programme to find first repeating element in an array
http://www.geeksforgeeks.org/find-first-repeating-element-array-integers/

31 Find a number in a 2-D matrix sorted horizontally and vertically.
http://www.geeksforgeeks.org/search-in-row-wise-and-column-wise-sorted-matrix/

32 How to find the minimum element in a rotated array? e.g. 4 5 6 1 2 3

33 How to know if a number is a power of 2 in O(1)?
n&(n-1)==0?true:false

34 Given n points in a plane which form a polygon. Find if a random point exists inside that polygon or not
http://www.geeksforgeeks.org/how-to-check-if-a-given-point-lies-inside-a-polygon/

35 There is a paragraph having million characters. You have to find out the first non –repeating character in the complete paragraph
http://www.geeksforgeeks.org/given-a-string-find-its-first-non-repeating-character/

36 There are N nuts and N bolts, u have to find all the pairs of nuts and bolts in minimum no. of iteration (comparision). All the nuts/bolts might have different diameter.
http://www.geeksforgeeks.org/nuts-bolts-problem-lock-key-problem/

37 There are chocolates each worth x. You have total amount y with you. And you can exchange z wrappers for 1 chocolate. So in this way how many chocolates he can eat.

38 There is a pond in which there is x kg ice on 1st November, it becomes 2x on 2nd November then 4x,8x,16x,32x and so on.Like this whole pond is filled with ice on last day i.e. 30th November. On which day pond was filled with half the ice ?

39 you have 100 coins on table, 60 heads and 40 tails. With your eyes closed, how can you separate the coins into 2 groups such that each group has same number of tails.

40 You have 3 jars that are all mislabeled. One jar contains Apple, another contains Oranges and the third jar contains a mixture of both Apple and Oranges.
You are allowed to pick as many fruits as you want from each jar to fix the labels on the jars. What is the minimum number of fruits that you have to pick and from which jars to correctly label them?
http://www.crazyforcode.com/3-mislabeled-jars/

41Find the row with maximum ones in a 2D array where in each row all 1s occur before all 0s
http://www.geeksforgeeks.org/find-the-row-with-maximum-number-1s/

42 Check if a given sum is availabe in an array.
http://www.geeksforgeeks.org/find-subarray-with-given-sum/

43 Design a ladder and Snake Problem with TWO Player and Code it.
http://www.geeksforgeeks.org/snake-ladder-problem-2/

44 A person can have 1 step, 2 step, or 3 steps. How much combination he can have to climb on a ladder of n and code.
http://www.geeksforgeeks.org/count-ways-reach-nth-stair/

45 In array only 1 element is unique rest are 2 times. How to find that?
http://www.geeksforgeeks.org/adobe-interview-set-16-mts-1/

46 Random Pointer in Linked list. Clone it.
http://www.geeksforgeeks.org/clone-linked-list-next-arbit-pointer-set-2/

47 There are 2 people A and B. Both A and B have equal speed of walking. Both A and B have equal speed of running. Now assume that A runs for half the time and walks for half the time. While, B runs for half the distance and walks for half the distance. Can we tell conclusively who will win in a race?
http://mathforum.org/library/drmath/view/58589.html

48 Find square root of ‘N’ without using square root function.

No comments :

Post a Comment