Software Engineer / Developer Interview Questions
- 2of 4 votes
AnswersGiven a binary tree return the level with maximum number of nodes
- ruddermechanic February 07, 2013 in United States1 / \ 2 3 /\ /\ 4 5 6 7 / \ 8 9
| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Trees and Graphs - 2of 4 votes
AnswersGiven a dictionary, and a list of letters ( or consider as a string), find the longest word that only uses letters from the string. [I didn't meet this question, what's the best solution?]
- Obiwana March 11, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 2of 4 votes
AnswersHow do you find the greatest 1000 elements in a list of a million elements? No other information given. What would be the runtime? Hint: You can do better than O(n log n). I didn't realize but it could be possible with Tree or Heaps.
- Ana April 23, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 4 votes
AnswersWrite a method to return first five 10 digit prime numbers.
- saudip100 July 22, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 2of 4 votes
AnswersGiven a sequence of numbers such that A[0] >= A[1] and A[N-1] >= A[N-2] find at-least one triplet such that A[n-1] >= A[n] <= A[n+1]. Better than linear time is expected.
- hsantosh71 June 15, 2013 in United States
Example: 9 8 5 4 3 2 6 7
Answer: 3 2 6| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 4 votes
AnswersSuppose u have a square matrix of 0s and 1s only ... find the longest path of 1s available in the matrix and return that .. you can only move right and down ... For e.g.
- Messiah January 20, 2013 in India
0 0 0 1 1
1 1 1 0 1
0 1 1 1 0
0 0 1 0 0
1 1 1 1 1| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer Algorithm - 2of 4 votes
AnswersHaving a table Genre with two colums (Id, Genre) make an SQL Query that finds the Ids with the genre Action and Comedy. (those will have multiple lines for each Id)
Answer:
- mikeldi10 June 19, 2014 in UK for Amazon Instant Videoselect g.id from (select id from genre where genre = 'Action') x, genre as g where g.id = x.id and genre = 'Commedy'
| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer SQL - 2of 4 votes
AnswersGiven two trees, find if tree 2 is the mirror image of tree 1.
- techpanja October 02, 2013 in United States| Report Duplicate | Flag | PURGE
Apple Software Engineer / Developer Data Structures - 2of 4 votes
AnswersA teacher wanted 100 gems distributed in 7 purses such that number of gems in 7 purses should always sum up to 100. But his condition was that he can demand any number of gems between 1 to 100 and Shiva must be able to satisfy his demand without needing to open any purse. Also once Shiva packs the purses, he will not get another chance to rearrange the number of Gems in those 7 purses. So consider that these purses are sealed the moment Shiva puts appropriate number of Gems in it.
- chouhan.mayank August 14, 2013 in India
Out of affection, the teacher decided to step up the difficulty level so that Shiva can survive the turbulent world outside the Gurukul. The Guru added one more condition that out of 7 purses Guru will always fill one purse with any number of gems. Thus Shiva need to distribute remaining Gems in rest of the 6 purses.
As a new techie your task is to write a computer program to help Shiva in fulfilling his Guru's demand.| Report Duplicate | Flag | PURGE
TATA Consultancy Services Software Engineer / Developer Algorithm - 2of 4 votes
AnswersGiven number of digits of a phone number and number of disallowed digits as input, find all permutations of numbers which do not have two adjacent numbers the same, i.e. 1232 is allowed but not 1223. Disallowed digits can be upto 3, and can be included along with the phone number. Also the phone number should start with 4 if it contains the number 4.
- hpfan1 October 18, 2014 in United States| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer - 2of 4 votes
AnswersImplement HashTable in java , especially hash function that should take care of any type of keys. The key may be integer or String or Object. But based on that the hash function should find index in the hashArray
- sivaji8 November 15, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures - 2of 4 votes
AnswersImplement LRU cache.
- iamthe0ne August 16, 2013 in United States| Report Duplicate | Flag | PURGE
Twitter Software Engineer / Developer Algorithm - 2of 2 votes
AnswersRound 1: Q2:
- Abee July 20, 2011
Puzzle
Given 25 horses, find the best 3 horses with minimum number of races. Each race can have only 5 horses. You don't have a timer.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Brain Teasers Highbridge Capital Deshaw Inc - 2of 2 votes
Answersfind the longest palindrome in a string?
- handiaya November 09, 2009| Report Duplicate | Flag | PURGE
Microsoft Amazon Software Engineer / Developer Algorithm Arrays C++ Coding String Manipulation C - 2of 2 votes
AnswersGiven a set top box:
- chandeepsingh85 September 26, 2013 in United States
a, b, c, d, e,
f, g, h, i, j,
k, l, m, n, o
p, q, r, s, t
u, v, w, x, y
z
Write code to give the character sequence given a word, For example, if the word is "CON", the function will print this:
Right//now we're at B
Right//now we're at C
OK//to select C
Down
DOwn
Right
Right
OK//to select O
Left//now at N
OK//to select N
note: Be careful when you're at Z. if you go to the right, you will get stuck.
Afterwards, the interviewer adds a space to the right of 'Z' to test the code.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Site Reliability Engineer String Manipulation Algorithm - 2of 2 votes
AnswersGiven an array and an integer k , find the maximum for each and every contiguous sub array of size k.
- abc February 15, 2011
Sample Input :
1 2 3 1 4 5 2 3 6
3 [ value of k ]
Sample Output :
3
3
4
5
5
5
6| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 2of 2 votes
AnswersWe define C(n) as the number of ways to take n identical objects out of a bucket, where objects may be taken 1, 2, or 3 at a time.
- skeptical.scientist January 05, 2013 in United States
Example: C(4)=7, because you can take 4 objects in the following 7 ways:
1,1,1,1
2,1,1
1,2,1
1,1,2
2,2
3,1
1,3
Write a function for C(n) in the language of your choice.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 2of 2 votes
AnswersYou are given an array of n elements [1,2,....n]. For example {3,2,1,6,7,4,5}.
- Biswajit Sinha October 26, 2012 in India
Now we create a signature of this array by comparing every consecutive pir of elements. If they increase, write I else write D. For example for the above array, the signature would be "DDIIDI". The signature thus has a length of N-1. Now the question is given a signature, compute the lexicographically smallest permutation of [1,2,....n]. Write the below function in language of your choice.
vector* FindPermute(const string& signature);| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersWrite a method that multiplies two integers without using multiply operator
- S.Abakumoff February 25, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven an array, find all maximal sub-arrays in which all pairs have their sum greater than k. DP would give us a O(n^2) algorithm. Can we do better.
- Vikas October 29, 2012 in United States
suppose k = 4
-4 9 10 4 -3 8 9 -2
Answer is:
-4 9 10
9 10 4
-3 8 9
8 9 -2| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven An Array with N integer with values ranging from 1 to N. there is only one duplicate in the Array.
- Geek December 09, 2012 in United States
Find out Duplicate value.
i.e.
A = { 10,6,3,4,7,5,2,4,9,1}
values from 1 to 10.
in this example, Duplicate element is 4.
N could be quite large.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 2of 2 votes
Answersgiven n > 0 fair dice with m > 0 "sides", write an function that returns a histogram of the frequency of the result of dice rolls. For example, for two dice, each with three sides, the results are:
- Aurelius October 29, 2014 in United States for BVal
(1, 1) -> 2
(1, 2) -> 3
(1, 3) -> 4
(2, 1) -> 3
(2, 2) -> 4
(2, 3) -> 5
(3, 1) -> 4
(3, 2) -> 5
(3, 3) -> 6
And the function should return:
2: 1
3: 2
4: 3
5: 2
6: 1| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Coding - 2of 2 votes
AnswersWrite the code to find lexicographic minimum in a circular array, e.g. for the array
- ALgeek September 25, 2012 in India
BCABDADAB, the lexicographic mininum is ABBCABDAD| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersFind the length of a linked list which contains cycle.
- test January 16, 2009| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Linked Lists - 2of 2 votes
AnswersConsider this string representation for binary trees. Each node is of the form (lr), where l represents the left child and r represents the right child. If l is the character 0, then there is no left child. Similarly, if r is the character 0, then there is no right child. Otherwise, the child can be a node of the form (lr), and the representation continues recursively.
- Itcecsa April 08, 2012 in United States
For example: (00) is a tree that consists of one node. ((00)0) is a two-node tree in which the root has a left child, and the left child is a leaf. And ((00)(00)) is a three-node tree, with a root, a left and a right child.
Write a function that takes as input such a string, and returns -1 if the string is malformed, and the depth of the tree if the string is well-formed.
For instance:
find_depth('(00)') -> 0
find_depth('((00)0)') -> 1
find_depth('((00)(00))') -> 1
find_depth('((00)(0(00)))') -> 2
find_depth('((00)(0(0(00))))') -> 3
find_depth('x') -> -1
find_depth('0') -> -1
find_depth('()') -> -1
find_depth('(0)') -> -1
find_depth('(00)x') -> -1
find_depth('(0p)') -> -1| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Algorithm - 2of 2 votes
Answershow would you merge two sorted arrays provided not to use a third array nor u can allocate extra space. try to optimize the problem to the best. time complexity should be less than O(n^2)
- not a looser January 19, 2009| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Software Engineer in Test Arrays - 2of 2 votes
AnswersFind the longest sequence of prefix shared by all the words in a string.
- employee11 July 15, 2014 in Israel
"abcdef abcdxxx abcdabcdef abcyy" => "abc"| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersYou have two numbers decomposed in binary representation, write a function that sums them and returns the result.
- getmax0 December 16, 2013 in United States
Input: 100011, 100100
Output: 1000111| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Bit Manipulation - 2of 2 votes
AnswersYou are given a 2D array of characters and a character pattern. WAP to find if pattern is present in 2D array. Pattern can be in any way (all 8 neighbors to be considered) but you can’t use same character twice while matching. Return 1 if match is found, 0 if not.
- NaiveCoder March 21, 2012 in India
eg :
Matrix
{'A','C','P','R','C'},
{'X','S','O','P','C'},
{'V','O','V','N','I'},
{'W','G','F','M','N'},
{'Q','A','T','I','T'}
And pattern is microsoft.
It's funny when google looks for pattern of microsoft ;)| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 2of 2 votes
AnswersGiven a document and a query of K words, how do u find the smallest window that covers all the words at least once in that document? (given you know the inverted lists of all K words, that is, for each word, you have a list of all its occurrrences). This one is really hard. Could someone propose an algorithm in O(n)?
- Anonymous November 11, 2009| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm