Software Engineer Interview Questions
- 1of 1 vote
AnswersYou are given printouts from an algorithm which ran over a sorted binary tree. One printout is from an in-order run and another from a pre-order run. Can you reconstruct the tree? If so, then write an algorithm.
- tested.candidate March 22, 2015 in UK| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersYou have N points on a 2D surface. List K points at a shortest distance to the point (0, 0).
- tested.candidate March 22, 2015 in UK| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 2 votes
AnswersThere is a company with 250 employees. Its records contain: EmployeeID, ManagerID (which is a reference to the EmployeeID of the manager).
- tested.candidate March 22, 2015 in UK
Part 1. List directly reporting employees for a given ID
Part 2. List all (also indirectly) reporting employees to a given ID| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersPart 1: You are given a computer #1 with array Foo, a computer #2 with array Bar and a spare computer #3. You need to apply a function F to corresponding/matching elements of the two arrays. How would you do that?
- tested.candidate March 21, 2015 in UK
Part 2: Once you scale up, how would you balance the number of machines sorting with the machines applying the function?
Part 3: What if the master (which is distributing the work) dies and never recovers?| Report Duplicate | Flag | PURGE
Google Software Engineer Distributed Computing - 1of 1 vote
AnswersYou are given two strings. String T is a string where characters need to be reordered. String O contains characters (none of them repeated) which defines the order/precendence to be used while reordering the string T. Write an algorithm to do the reordering.
- tested.candidate March 21, 2015 in Switzerland
*** SPOILER ALERT ***
The question was pusposefully underspecified - upon questioning it was revealed that the string O might not necessarily include all characters used in string T - the characters not included in string O are supposed to be placed at the beginning of the resulting string (in no particular order).| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersYou are given two arrays - A & B. The length of the arrays is the same - N. The values in the arrays are integers from 0 to N - 1 in random order and no number is repeated. You need to list a sequence of two-element swaps required to reorder the array A into the order of the array B. Additionally, at each step of the sequence you are allowed to swap two elements only if one of them is 0.
- tested.candidate March 21, 2015 in UK| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - -1of 1 vote
AnswersGiven a tokenized PHP file, give me a map from class to list of functions
- Kiara March 19, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 1of 1 vote
AnswersGiven two sparse Vectors, compute the Dot Product.
- rksharma008 March 19, 2015 in United States
Input Format : The first line will contain two numbers(k and n), which are the number of entries for the two vectors respectively.
The next k lines are the entries for the first vector, of the form : x y
where x is the position and y is the value at that position in the vector.
The n lines are the entries of the second vector.
Any entries not specified indicate zero at that position.
The two vectors will always be of the same length
Example input:
3 3
1 4
4 2
5 3
1 7
2 6
5 1
Sample Answer: Dot Product = 4*7+3*1 = 31 (only print 31)| Report Duplicate | Flag | PURGE
Yelp Software Engineer - 1of 1 vote
AnswersCheck if the given binary tree is a unival tree. (all nodes have same value)
- tbag March 16, 2015 in United States
Follow up- Count the number of unival subtrees in a binary tree.| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 0of 0 votes
AnswersGiven an integer of a certain bit length, does it have an even or odd number of parity bits?
- tbag March 16, 2015 in United States
Optimization - Can you do this recursively in one line of code?| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 0of 0 votes
AnswersWrite a function ShortestPath which accepts an integer array with dimensions M and N, and two points P and Q.
- tjcbs2 March 16, 2015 in United States
The array represents a terrain grid. A value of '0' means the terrain at that location can be crossed, '1' means the terrain is impassible. P and Q represent two locations in the grid.
The function is to find and return the shortest path from P to Q. If there is no path, then return an empty path.| Report Duplicate | Flag | PURGE
Software Engineer Algorithm - 3of 3 votes
AnswersImplement stairs(N) that (collect the solutions in a list) prints all the ways to climb up a N-step-stairs
- pk March 14, 2015 in United States
where one can either take a single step or double step.
We'll use 1 to represent a single step, and 2 to represent a double step.
stairs(3)
111
12
21| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 1of 5 votes
AnswersWrite a function that takes an integer as input and produces an output string.
- tbag March 11, 2015 in United States
Some sample Input/outputs are as follows
i/p o/p
1 - A
2 - B
3 - AA
4 - AB
5 - BA
6 - BB
7 - AAA
8 - AAB
9 - ABA
10 - ABB
11 - BAA
12 - BAB
13 - BBA
14 - BBB
15 - AAAA| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 3of 5 votes
AnswersA robot has to move in a grid which is in the form of a matrix. It can go to
- thisandthat March 09, 2015 in United States
1.) A(i,j)--> A(i+j,j) (Down)
2.) A(i,j)--> A(i,i+j) (Right)
Given it starts at (1,1) and it has to go to A(m,n), find the minimum number of STEPS it has to take to get to (m,n) and write
public static int minSteps(int m,int n)
For instance to go from (1,1) to m=3 and n=2 it has to take (1, 1) -> (1, 2) -> (3, 2) i.e. 2 steps| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 1of 1 vote
AnswersHow would you optimize an elevator system for a building with 50 floors and 4 elevators ? Optimize in terms of lowest wait times for the users. Nothing related to power consumption.
- tbag March 08, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer System Design - 0of 0 votes
AnswersIn C++, what's the difference between public and private? what's the purpose of this and please illustrate a design example with this.
- ycw March 07, 2015 in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer C++ - 0of 0 votes
AnswersGiven the interface below, implement a task scheduler.
interface Task { void Run(); Set<Task> GetDependencies(); }
Additionally, the task scheduler should follow two rules.
- John March 07, 2015 in United States
1. Each task may only be executed once.
2. The dependencies of a task should be executed before the task itself.| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 1of 1 vote
AnswersCreate a maze.
- marinalepi March 06, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Problem Solving - 0of 0 votes
AnswersPlay Scrabble. You have 7 letters to start from. Build the word with the highest score.
- marinalepi March 06, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer String Manipulation - 5of 5 votes
Answers
- Alex March 04, 2015 in United StatesQuestion: Given two strings, find number of discontinuous matches. Example: “cat”, “catapult” Output: 3 => “CATapult”, “CatApulT”, “CAtapulT”
| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersCrypt Analysis problem :
- akii March 03, 2015 in United States
The Interviewer told me to implement the following interface
interface Expression {
Set<Char> getChars();
boolean eval(Map<Char, Int> m);
}
Map will contain values like
{ 'O' => 2, 'N' => 3, 'E' => 1, ... 'T' => 4 , } :
And eval function evaluates if the answer is correct or not , input will have 3 strings operand1 , operand2 and answer .
Overall the question was not complete , so I asked him again and again that I just have to verify the answer and not calculate it .
Verifying was really easy just get the values from map and convert to int . Add them and verify if the answer is correct.
Cam someone tell if my assumption is correct about the problem .
Example:
ONE
+ONE
----
TWO
231
+231
----
462
FOUR
+FOUR
-----
EIGHT
5239
+5239
-----
10478| Report Duplicate | Flag | PURGE
Palantir Technology Software Engineer Algorithm - 0of 0 votes
AnswersThis is the screening question from Dropbox. I see it appear in other topics as the question in the interview. However I did not find a complete solution so I put my discussion here (http://www.capacode.com/?p=447) for your reference.
- truongkhanh March 02, 2015 in United States
Question: Given a pattern and a string, check whether the string matches the pattern. For example: pattern "aba" and the string is "redblackred" then it matches because "a" is translated to red and "b" is translated to "black". Note that for each character in the pattern, the translation is not empty and unique.| Report Duplicate | Flag | PURGE
Dropbox Software Engineer Algorithm - 3of 3 votes
AnswersQuestion: Given a sequence of positive integers A and an integer T, return whether there is a continuous sequence of A that sums up to exactly T
- ep February 27, 2015
Example
[23, 5, 4, 7, 2, 11], 20. Return True because 7 + 2 + 11 = 20
[1, 3, 5, 23, 2], 8. Return True because 3 + 5 = 8
[1, 3, 5, 23, 2], 7 Return False because no sequence in this array adds up to 7| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 0 votes
AnswersParsing CSV input into a list of tokens. Exception: a comma in double quote is considered inside of a token. Two double quotes inside is considered an escape to one double quote in the token.
- CC February 26, 2015 in United States
example:
a, b, c ===>
a
b
c
a, "b", c ==>
a
b
c
a, "b, x" , d ==>
a
b,x
d
a, "b, x,""", d ==> 'a' 'b,x"' 'd'
a
b,x,"
d| Report Duplicate | Flag | PURGE
Software Engineer Algorithm - 0of 0 votes
AnswersIf I was a marketer for a large company, tell me how I can increase the number of likes I have on my Facebook business page to 5 million?
- LeetJile February 24, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer Ideas - 2of 2 votes
AnswersConsider the 52 cards of a deck. You generated a random sequence for these cards and want to send that sequence to a receiver. You want to minimize the communication between you and the receiver, i.e., minimize the number of bits required to send the sequence.
- eng.ahmed.moustafa February 23, 2015 in United States
What is the minimum number of bits required to send the sequence?
Hint: It is not 6 x 52| Report Duplicate | Flag | PURGE
Google Software Engineer Arrays - 2of 2 votes
AnswersInput: A string equation that contains numbers, '+' and '*'
- huji February 23, 2015 in Israel
Output: Result as int.
For example:
Input: 3*5+8 (as String)
Output: 23 (as int)| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 1of 1 vote
AnswersGiven a class Range
class Range { public int begin; public int end; public Range(int begin, int end) { this.begin = begin; this.end = end; } }
The problem:
- huji February 23, 2015 in Israel
Intput:
1) list of Ranges that don't overlap (not sorted)
2) newRange that might overlap.
Output:
list of merged Ranges
For example:
Input: [1..5] [9..13] [17..22]
newRange: [4..10]
Output: [1..13] [17..22]| Report Duplicate | Flag | PURGE
Facebook Software Engineer