Recent Interview Questions
- 2of 2 votes
AnswersGiven a string with only parenthesis. Check if the string is balanced.
- teli.vaibhav October 30, 2016 in United States
ex -
1) "<({()})[]> is balanced
2) "<({([)})[]> is not balanced| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 2of 2 votes
AnswersTwo strings s1 and s2 are given. You have make a new string s3 such that it has both s1 and s2 as one of its subsequences and length of s3 is minimum.
- ritwik_pandey September 03, 2015 in India
input:
apple pear
output:
applear
7| Report Duplicate | Flag | PURGE
Alcatel Lucent Developer Program Engineer - 2of 2 votes
AnswersGiven an array of positive integers(>0) , you have to insert '+','*','(',')' signs basically plus multiply and brackets such that value of resultant expression becomes maximum.
- smarthbehl August 25, 2015 in United States
Hint: Consider case of continuous ones
You have to print the resulting expression| Report Duplicate | Flag | PURGE
Adobe Computer Scientist Algorithm - 2of 2 votes
AnswersCount triangles in an undirected graph where a triangle is a unique set of three vertices connected to one another.
- tested.candidate July 14, 2015 in Switzerland| Report Duplicate | Flag | PURGE
Google Software Developer Algorithm - 2of 2 votes
AnswersThere is a compressed string eg. ”ab2c3”, the string has lowercase characters and numbers. We can uncompress the given string as follows: whenever we get a number “n” in the string, the portion of the string before the number will repeat “n” times. So in the above example, we get a 2, so string will become “ababc3”, now we get a 3, so final string will be “ababcababcababc”.
- Rahul Sharma August 28, 2014 in India
Given a compressed string and a number k, you have to output the k’th character in the uncompressed string.
1 <= length of string <= 1500
1 <= n <= 1000
1 <= k < 2^31
example:
input: ab2c3 10
output: c| Report Duplicate | Flag | PURGE
Directi SDE1 Algorithm - 2of 2 votes
AnswersWrite an application in Java to simulate file system. For e.g. implement commands: ls -l (list contents of director sorted by name), cd .. (to go to parent directory), pwd to return the complete path to current directory etc. It was a 2 hour remote programming test.
- techpanja February 13, 2014 in United States
Your system will have Directory and Files. A directory can contain files and other directories.| Report Duplicate | Flag | PURGE
Salesforce Software Engineer / Developer - 2of 2 votes
AnswersLucky numbers are those numbers which contain only "4" and/or "5". For example 4, 5, 44, 54,55,444 are lucky numbers while 457, 987 ,154 are not.
- sunny.010203045 January 29, 2014 in India
Lucky number sequence is one in which all lucky numbers exist in increasing order for example 4,5,44,45,54,55,444,445,454,455...
Now we concatenate all the lucky numbers (in ascending order) to make a lucky string "4544455455444445454455..."
Given n, your task is to find the nth digit of the lucky string. If the digit is 4 then you have to print "Hacker" else you have to print "Earth".
Input:
first line contain number of test cases T , next T line contain a single interger n.
Output:
For each test case print "Hacker"(without quotes) if nth digit of lucky string is "4" else print "Earth"(without quotes) if nth digit of lucky string is "5".
Constraints:
1<=t<=10^5
1<=n<=10^15| Report Duplicate | Flag | PURGE
Amazon SDE1 - 2of 2 votes
AnswersIs it possible to compare two Binary trees for equality in iterative manner without using extra space?
- Algorithmist June 17, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 2of 2 votes
AnswersProblem: you are given 2 words with equal number of characters. Find an algorithm to go from first word to second word, changing one character at each step, in such a way that each intermediate word exist in a given dictionary.
- EugenDu May 24, 2013 in United States
Example:
Words are pit, map. A possible solution:
pit, pot, pet, met, mat, map| Report Duplicate | Flag | PURGE
Ebay Software Engineer in Test Algorithm - 2of 2 votes
AnswersGiven a list of n points in 2D space. Lets call them (X1,Y1), (X2,Y2) .... (Xn,Yn). Find the optimal way to retrieve the result of following query.
- Amm Sokun May 22, 2013 in India
SELECT min(X) FROM (2D Points) WHERE Y between Ymin and Ymax.| Report Duplicate | Flag | PURGE
Microsoft SDE1 Algorithm - 2of 2 votes
AnswersYou have a very very big text file.How would you read & process it to print the below output.
- cCAACc April 20, 2013 in United States
1. Print the top ten ranked distinct words.
2. Print the occurrence of the each alphabet in this file.
For example:
ABC (100)
XYZ (40)
PQR (10)
THE (200)
IN (200)
Then I have to display the output as
IN (200)
THE (200)
ABC (100)
XYZ (40).
And
A=1000
B=2000
C= 300
.. ...
z=300| Report Duplicate | Flag | PURGE
Citigroup Financial Software Developer String Manipulation - 2of 2 votes
AnswersCreate a function that will reverse the words in a sentence.
- Kevin.Pheasey April 10, 2013 in United States for AWS| Report Duplicate | Flag | PURGE
Amazon Web Developer JavaScript - 2of 2 votes
AnswersYou are given an array of size N containing negative and positive real numbers. Zero may or may not be present in the array. The requirement is to rearrange the array using O(N) time and O(1) space so that all negative numbers come before all positive elements. Develop a program to read a real number array of size N from user, and then arrange it as explained above.
- rohit February 22, 2013 in India
Constraints :
(i) The value of N has to be read from user, and the memory for array has to be allocated dynamically. The real numbers will be also read from user. The menu-driven program should also have an option to populate the array with random data, if the user wants to do so.
(ii) A maximum of 3 passes allowed over the entire array. O(N) time expected.
(iii) O(1) extra space permitted – creating copy of array etc not allowed.
(iv) Program must work properly even if zero is NOT present in array.| Report Duplicate | Flag | PURGE
IBM Software Engineer in Test - 2of 2 votes
AnswersGiven a 2D array of size m X n, containing either 1 or 0. As we traverse through, where ever we encounter 0, we need to convert the whole corresponding row and column to 0, where the original value may or may not be 0. Now devise an algorithm to solve the problem minimizing the time and space complexity.
- mrinalkamboj December 18, 2012 in India for Bing| Report Duplicate | Flag | PURGE
Microsoft Tech Lead Algorithm - 2of 2 votes
AnswersYou are given N blocks of height 1…N. In how many ways can you arrange these blocks in a row such that when viewed from left you see only L blocks (rest are hidden by taller blocks) and when seen from right you see only R blocks? Example given N=3, L=2, R=1 there is only one arrangement {2, 1, 3} while for N=3, L=2, R=2 there are two ways {1, 3, 2} and {2, 3, 1}.
- game January 21, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
Answersfind nearest word from the given non-english dictionary which is one off character. (could be non ascii characters)
- prathji October 01, 2019 in United States
for eg. dictionary contains { apple, pineapple, banana, orange }
if given word "applx" then return true, as applx matches with apple and only one character is off.
aplpe returns false| Report Duplicate | Flag | PURGE
Google Software Developer - 2of 2 votes
AnswersGive an positive integer n, find out the smallest integer m, such that all digits in m multiply equals to n. For example, n = 36, return 49. n = 72, return 89. You can assume there is no overflow.
- aonecoding June 06, 2018 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 2of 2 votes
AnswersThere is a maze of size m*n. You are sitting at (0,0). Another person is sitting in another cell. There are some cheeses placed in different cells with a cell value of 2. Some cells are blocked with a value of 1, thus you cannot pass it, while some cells are filled with 0, thus you can pass it.
- ajay.raj September 08, 2017 in United States
You can move to left, right, up, down at each step. You have to collect all the pieces of cheese and then reach to Another Person cell. You need to return the minimum no. of steps required to do so.
Public int getShortest(int[][] maze, int[] anotherPersonCell){
}| Report Duplicate | Flag | PURGE
Facebook SDE1 - 2of 2 votes
AnswersGiven an array of ints and a value X, find wether there are 3 elements in the array such that their sum is X (return true/false).
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 2of 2 votes
AnswersGiven a Binary tree and value X. Find X in the tree and return its parent
- neelabhsingh January 18, 2017 in India for Hyderabad
X:
10
4 3
5 7 9 8
If X = 7, return 4| Report Duplicate | Flag | PURGE
Amazon SDE-2 Trees and Graphs - 2of 2 votes
Answersfind the maximum depth in a binary tree.
- pooja January 31, 2016 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer Intern - 2of 2 votes
AnswersYou know result of a soccer match, print all the possible ways that this game ends up with this result.
- u-11i24223 December 01, 2015 in United States
Example: final score 1 - 1:
0 - 0
0 - 1
1 - 1
0 - 0
1 - 0
1 - 1
Another example if the final score is 2 - 3 there are many possibilities for reaching to that score:
2 - 3
0 - 0
1 - 0
2 - 0
2 - 1
2 - 2
2 - 3
0 - 0
1 - 0
1 - 1
1 - 2
2 - 2
2 - 3
0 - 0
0 - 1
0 - 2
0 - 3
...| Report Duplicate | Flag | PURGE
unknown Software Engineer Algorithm - 2of 2 votes
AnswersWe have an iterator class as below:
class CIterator { int Next(); //Returns the value of the next element in the iteration by advancing the iterator bool HasNext() const; //check whether any next element for the current iterator };
We need a CPeekIterator class which is having below functionalities
Class CPeekIterator { int Next (); //Same as CIterator does bool HasNext() const; //same as CIterator does int Peek(); // Returns the next element in the iteration without advancing the iterator };
Write the CPeekIterator class
- johnsvakel November 24, 2015 in United States for GFS| Report Duplicate | Flag | PURGE
Google SDE1 Algorithm - 2of 2 votes
AnswersThere is a circular train (the head is connected to the tail) where each car of the train contains a light bulb. Initially, the bulbs are randomly switched on/off.
- pavel.em November 04, 2015 in Germany
You need to determine the size of the train (the number of cars)
by going from one car to another and switching the light bulbs| Report Duplicate | Flag | PURGE
Yandex Software Engineer / Developer Algorithm - 2of 2 votes
Answerswrite a function that detects conflicts in given meeting schedules
- bazinga March 24, 2015 in United States
input: a list of intervals, [(s1, e1), (s2, e2), ]
output: return True if there's any conflict, False otherwise| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 2of 2 votes
AnswersMutiplicative iteration.Assume letters are A=1,B=2....The number N=4 then A=1*4=4.If result is greater than 26 mod 26.Input a string and give a encrypted result as output.
- chutzpah February 11, 2015 in United States| Report Duplicate | Flag | PURGE
Epic Systems Software Developer - 2of 2 votes
AnswersPrint a BST such that it looks like a tree (with new lines and indentation, the way we see it in algorithms books).
- Ray December 22, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 2of 2 votes
AnswersGiven an array of type:-
- anupjunagadecat November 25, 2014 in India for 11
1. Increasing
2. Decreasing.
3. Increase-Decrease
4. Decrease-Increase
Find:- 1. Type of array in minimum steps ?
2. Maximum element from array in min steps?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGot this sh***y problem.
- Hitman October 31, 2014 in United States
A judge tells a person under trial that if your answer is true, you get 2 year sentence and if your answer is false you get 3 year sentence. The person under trial gives an answer which made the judge set him free. What did he say?| Report Duplicate | Flag | PURGE
Oracle Puzzle - 2of 2 votes
AnswersGiven a file containing a list of ip addresses that have lost their dots(.'s), write a program to find the ip addresses, assume ipv4. input: 11111 output. 1.1.1.11, 11.1.1.1, etc
- rk August 09, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1