Vous êtes sur la page 1sur 4

APTITUDE TEST 2: 60 minutes, 3 programs, no compiler was provided, but you have to type the codes and submit.

More than syntax your logic, approach, running time and algorithm mattered. You can navigate around the three codes. Any language is alright. Q 1) Given an unsorted array and a number N, find a tuple which has a difference of N. If it exists return true else return false. (We all assumed tuple to be any two numbers in the array, I used a hash map, so O(N) time and O(N) space)

Q2) Given a circular linked list, insert an element such that after inserting it, the linked list remains sorted. (Consider all cases, inserting in the beginning, end and middle, basically I wrote the insert function such that it creates a sorted circular linked list).

Q 3) Given a binary search tree and a number N in the tree, at whatever level N exists in the tree (say k), of that level print the left most node. (Binary search tree property is of no use here, find the level of N in the tree ,say it is k, and then print the nodes at level k from root from left to right, when first node at k gets printed, stop printing, maintain a static or reference variable for the same . I did not get this one perfectly during the test, so that was the first thing I was asked in my level one interview!!)

INTERVIEW ONE : He scanned through my resume and asked questions, so make sure you write stuff about which you can give at least some idea. I had mentioned about ciphers I had coded, so I was asked questions on network security. Some of the questions I was asked were 1) What is the difference between a thread and a process? 2) What is synchronization? Acquiring and releasing a lock etc

3) What is buffer overflow? Why does it happen? What is the effect of it? How can u prevent it? Write a code snippet where buffer overflow happens.( I wrote a strcpy where source was smaller than destination) 4) As I spoke something about canary variable he asked me about that. Make sure u do not just get words out of your mouth because you read it somewhere, If you do not know the meaning ,dont mention it 5) Symmetric and asymmetric cipher, pros and cons of each. 6) Asked me about my final year project, I said we have not finalised the topic. 7) Asked me what I like , what do I think I am good at?(answer expected was technical, not HR type) 8) This was a coding question, I had to give the algorithm, after he was convinced, I had to write the working code: Given a string like aaabbbdddaccc compress it IN PLACE . (Basically, run length encoding, but elements that occur once you do not have to mention their count, as in abc remains abc ) INTERVIEW TWO: 1) Difference between recursion and iteration, pros and cons 2) Write code for Nth Fibonacci number iteratively, what is the disadvantage of doing it recursively. 3) Which is the longest code you wrote till now? Which is the toughest code you wrote till now? 4) Given a binary tree, node structure has data, left, right and next ,where next of every node is NULL. Now you must make every next point to the immediate next node on the same level( as in next one on the right). Convert every level of the binary tree into a circular linked list (populate all the next pointers) Do not destroy the binary tree while doing this, tree structure must be retained. (I came up with an algo of using an array of node pointers, size of array equal to height of the tree something like that. after he was convinced, I had to write the working code, after which I was asked to consider some test cases etc)

5) How do you think a dictionary is implemented in a phone or whatever? (using a trie , I did not know the name trie , but explained the possible structure which turned out to be a trie! )

INTERVIEW THREE: A single question was asked but he asked it in different modified ways to check if could handle all the ways.

Given a binary search tree, and a number N, return true if there exists a path in the BST which sums up to N. Otherwise return false.(Not necessarily a root to leaf path, any path)( I gave an n square solution) Then he told to print the path without using an auxiliary array instead of returning true or false. Then he asked me to store the start and end pointers of that path Then he was like if I have given you a start and end node, just print that path.(I used the BST property here) INTERVIEW FOUR:

1) Asked about my TGMC project (as it was mentioned in my resume) and my role in it. 2) Given a linked list, alternate every two elements. (I gave the algo , then wrote the working code .My code had repeated if else fragments, so it was too long to read, so he asked me to reduce the redundancy, after which I was asked about test cases)

3) Given an unsorted array, store in the beginning of the array, one occurrence of every element in the array,(basically a set form of the array) Input:1,6,7,3,5,2,7,3,1,6 Output:1,6,7,3,5,2 no importance given to what happens to the remaining part of array!! (Order of elements in output is not important, I suggested using built in SET which he did not allow, so I suggested sorting the array and proceeding, I was asked to write the working code) 4) Given a table having names and phone numbers, print all erroneous phone numbers. (I suggested making a regular expression for all possible phone patterns and check each entry with the regular expression. i gave examples of invalid phone numbers)

Tips: 1) Do not fake something if you do not know it, be honest 2) If you are unable to handle certain test cases it is okay, but then if you yourself point out the bugs and the cases which have not been handled, leaves a positive impact. 3) Remain calm and confident because the interviewers are cool and friendly. 4) It is okay to give slightly wrong answers at times, because when they know you are close to the correct answer, they push you to get it right. They know when to help and get it out from you. 5) No HR questions were asked , but just have some background about the company, and your strength , weakness etc.

6) Geeks for geeks and career cup were the websites I had referred to for all my coding related preparation. ALL THE BEST !!!

Vous aimerez peut-être aussi