Software Engineer Interview Questions
- 0of 0 votes
AnswersList of processes with start time, end time and bandwidth. Find the maximum bandwidth for the list.
- bottomcoder October 13, 2017 in United States
2. Given N teams which need to play each other exactly once but at most once in one day, output the game schedule.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 0of 0 votes
AnswersSnake and ladder game. Given a board state with position information for snakes and ladders, find the minimum number of ways(aka dice throws) one can reach from start to end.
- bottomcoder October 13, 2017 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 0of 0 votes
AnswersLongest substring palindrome
- bottomcoder October 13, 2017 in United States
(interview looking for n^2 or less solution)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 2of 2 votes
AnswerAirbnb Online Assessment Paginate List
- aonecoding October 13, 2017 in United States
5
13
1,28,310.6,SF
4,5,204.1,SF
20,7,203.2,Oakland
6,8,202.2,SF
6,10,199.1,SF
1,16,190.4,SF
6,29,185.2,SF
7,20,180.1,SF
6,21,162.1,SF
2,18,161.2,SF
2,30,149.1,SF
3,76,146.2,SF
2,14,141.1,San Jose
Here is a sample input. It’s a list generated by user search.
(1,28,100.3,Paris) corresponds to (Host ID, List ID, Points, City).
5 in the first row tells each page at most keeps 5 records.
13 in the second row is the number of records in the list.
Please paginate the list for Airbnb by requirement:
1. When possible, two records with same host ID shouldn’t be in a page.
2. But if no more records with non-repetitive host ID can be found, fill up the page with the given input order (ordered by Points).
Expected output:
1,28,310.6,SF
4,5,204.1,SF
20,7,203.2,Oakland
6,8,202.2,SF
7,20,180.1,SF
6,10,199.1,SF
1,16,190.4,SF
2,18,161.2,SF
3,76,146.2,SF
6,29,185.2,SF -- 6 repeats in page bec no more unique host ID available
6,21,162.1,SF
2,30,149.1,SF
2,14,141.1,San Jose| Report Duplicate | Flag | PURGE
Airbnb Software Engineer Algorithm - 2of 2 votes
AnswersFind the indices of all anagrams of a given word in a another word.
- aonecoding October 09, 2017 in United States
For example: Find the indices of all the anagrams of AB in ABCDBACDAB (Answer: 0, 4, 8)| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 1of 1 vote
AnswersGiven 2 words, return true if second word has a substring that is also an anagram of word 1.
- anonymous October 07, 2017 in United States
LGE , GOOGLE- True
GEO, GOOGLE - False| Report Duplicate | Flag | PURGE
Google Software Engineer - 1of 1 vote
AnswersGiven two list of unsorted intervals V1 and V2 write 2 functions 'OR ' and 'And' to return a new list
- sachin323 October 05, 2017 in United States
OR Function (union of list ): Input V1 = (2,4) (6,8) (1,3) V2 = (7,9) (2,5)
output = (1,5) (6,9)
And function : This will be intersection function and will return intersection of the lists| Report Duplicate | Flag | PURGE
Uber Software Engineer Algorithm - 0of 0 votes
AnswersCheck if two DOM Trees have the same text.
- wtcupup2017 September 28, 2017 in United States
e.g. <html><p>hello</p></html>, <html><p><b>h</b>ello</p></html> should be the same text
DOMNode class definition (string tag, string text, bool isText, vector<DOMNode*> children)| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 1of 1 vote
Answerscreate a class of integer collection,
- aonecoding September 22, 2017 in United States
3 APIs:
append(int x),
get(int idx),
add_to_all(int x),
in O(1) time。
Follow-up:
implement
multiply_to_all(int x)
e.g.
insert(1)
insert(2)
add_to_all(5)
insert(3)
get(0) -> returns 6
get(2) -> return 3
multiply_to_all(10)
insert(4)
get(1) -> returns 70
get(2) -> returns 30
get(3) -> returns 4| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersLonely Pixel
- aonecoding September 22, 2017 in United States
Given an N x M image with black pixels and white pixels, if a pixel is the only one in its color throughout its entire row and column, then it is a lonely pixel. Find the number of lonely pixels in black from the image. (O(NM))| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 3of 3 votes
AnswersFind max size of contiguous shape below, where X represents a shape and . is empty:
- steez September 21, 2017 in United States
.XXXXXX....
...X..XX..X
...XXXX....
..X.....X..
..XXX..XX..
.....XX....
/*method stub*/
public int GetMaxShape(char[][] array) {
}
i was able to come up with a recursive solution but i'd love tips on a dp solution| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
AnswersInserting dashes between two odd numbers and star between two even numbers
- praveenz.poola September 15, 2017 in India| Report Duplicate | Flag | PURGE
JP Morgan Software Engineer - 2of 2 votes
AnswersPrint Common Suffix In Strings
- praveenz.poola September 15, 2017 in India
Ex: cornfiled , Exfiled --- field| Report Duplicate | Flag | PURGE
Cisco Systems Software Engineer Java - 0of 0 votes
AnswersGiven an unsorted array. for example [2, 3, 1, 4, 5].
- OldChang September 12, 2017 in United States
Sort the array, we have new array [1, 2, 3, 4, 5],
if we draw the line between the 2 arrays for the same number, for example:
[3, 2, 1,4,5]
\ | /
\|/
/|\
[1, 2, 3,4,5]
then we have 3 line-cross:
line (1 to 1) cross line (2 to 2)
line (1 to 1) cross line (3 to 3)
line (2 to 2) cross line (3 to 3)
Note: the line between two 4s and the line between two 5s don't cross any other lines;
Implement the algorithm to calculate the how many line crosses for an unsorted array.| Report Duplicate | Flag | PURGE
Software Engineer Algorithm - 0of 0 votes
AnswersYou are given an alphanumeric string. Complete the function sortSegments that will segment the string into substrings of consecutive letters or numbers and then sort the substrings.
- Smart September 11, 2017 in United States
For example, the string "AZQF013452BAB" will result in "AFQZ012345ABB". The input letters will be uppercase and numbers will be between 0 and 9 inclusive.| Report Duplicate | Flag | PURGE
Software Engineer - 0of 0 votes
AnswersYou are given an integer array n. Complete the function sortIntegers which takes as an argument, an integer array n of up to 1 million integers such that 1 <= n_i <= 10.
- Smart September 11, 2017 in United States
for every element n_i in the array, and returns the sorted array. The sort does not need to occur in-place.
Please do not call a standard sorting function like quicksort, you can do better. A sample input is {3, 1, 4, 1, 5, 9, 2, 6, 5} and the corresponding output is {1, 1, 2, 3, 4, 5, 5, 6, 9}. Constraints: i <= 10^9; 1 <= n_i <= 10| Report Duplicate | Flag | PURGE
Software Engineer - 3of 3 votes
AnswersThis was a 3 hours coding round in which we had to code 1 problem having 50 test cases. Only those students were selected for the next round who passed all the test cases. Here is the question:
- jatinbansal321 September 08, 2017 in India
You’ll be given a grid as below:
0 1 0 2 0
0 2 2 2 1
0 2 1 1 1
1 0 1 0 0
0 0 1 2 2
1 1 0 0 1
x x S x x
In the grid above,
1: This cell has a coin.
2: This cell has an enemy.
0: It contains nothing.
The highlighted(yellow) zone is the control zone. S is a spaceship that we need to control so that we can get maximum coins.
Now, S’s initial position will be at the center and we can only move it right or left by one cell or do not move.
At each time, the non-highlighted part of the grid will move down by one unit.
We can also use a bomb but only once. If we use that, all the enemies in the 5×5 region above the control zone will be killed.
If we use a bomb at the very beginning, the grid will look like this:
0 1 0 2 0
0 0 0 0 1
0 0 1 1 1
1 0 1 0 0
0 0 1 0 0
1 1 0 0 1
x x S x x
As soon as, the spaceship encounters an enemy or the entire grid has come down, the game ends.
For example,
At the very first instance, if we want to collect a coin we should move left( coins=1). This is because when the grid comes down by 1 unit we have a coin on the second position and by moving left we can collect that coin. Next, we should move right to collect another coin( coins=2).
After this, remain at the same position( coins=4).
This is the current situation after collecting 4 coins.
0 1 0 2 0 0 1 0 0 0
0 2 2 2 1 -->after using 0 0 0 0 1
x x S x x -->bomb x x S x x
Now, we can use the bomb to get out of this situation. After this, we can collect at most 1 coin. So maximum coins=5.| Report Duplicate | Flag | PURGE
Samsung Software Engineer - -1of 1 vote
AnswersEmployees Per Department
- aonecoding September 05, 2017 in United States
Twitter Interview Online Test SQL
A company uses 2 data tables, Employee and Department, to store data about its employees and departments.
Table Name: Employee
Attributes:
ID Integer,
NAME String,
SALARY Integer,
DEPT_ID Integer
Table Name: Department
Attributes:
DEPT_ID Integer,
Name String,
LOCATION String
View sample tables:
https://s3-us-west-2.amazonaws.com/aonecode/techblog/50cfcdd1d61f1bd6002cf4d3b4a61deb-min.jpeg
Write a query to print the respective Department Name and number of employees for all departments in the Department table (even unstaffed ones).
Sort your result in descending order of employees per department; if two or more departments have the same number of employees, then sort those departments alphabetically by Department Name.| Report Duplicate | Flag | PURGE
Twitter Software Engineer SQL - 1of 1 vote
AnswersThe numbers on a telephone keypad are arranged thus:
1 2 3 4 5 6 7 8 9 0
Starting from any digit, and choosing successive digits as a knight moves in chess, determine how many different paths can be formed of length n. There is no need to make a list of the paths, only to count them.
- ajay.raj September 04, 2017 in United States
A knight moves two steps either horizontally or vertically followed by one step in the perpendicular direction; thus, from the digit 1 on the keypad a knight can move to digits 6 or 8, and from the digit 4 on the keypad a knight can move to digits 3, 9 or 0. A path may visit the same digit more than once.
Your task is to write a function that determines the number of paths of length n that a knight can trace on a keyboard starting from any digit .
public int findNumberOfPaths(int digit, int step){| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 1of 1 vote
Answers## This is the text editor interface.
- wonderkid September 02, 2017 in United States
## Anything you type or change here will be seen by the other person in real time.
# Implement the function that takes a board string
# and decodes it into the representative 2D array.
#
# |_|_|_|_|_|_|_|
# |_|_|r|_|_|_|_|
# |b|r|b|r|b|r|_|
# |b|b|b|r|r|b|_|
# |b|r|r|b|b|r|_|
# |r|b|b|r|r|r|b|
# CFN: 9_r4_brbrbr_3b2rb_b2r2br_r2b3rb
#
# This function should return a list of lists of strings.
# (i.e. a string[6][7]). The strings should be one of:
# * 'r' to indicate a red piece
# * 'b' to indicate a black piece
# * '_' to indicate an empty space
#
# The input string is not necessarily a valid
# CFN board string. It is guaranteed not-empty.| Report Duplicate | Flag | PURGE
Palantir Technology Software Engineer Python - 1of 1 vote
AnswerIII. Square root of a number?
- aonecoding August 30, 2017 in United States
IV. Expression operators? Add signs (+, -, *, /) to a string to form target
V. Top trending posts in last 5m, 1H, 1Day?| Report Duplicate | Flag | PURGE
Linkedin Software Engineer Algorithm - 0of 0 votes
AnswersI. Closest K nodes to a target in BST? (Do it in O(n)?)
- aonecoding August 30, 2017 in United States
II. Nested List sum?| Report Duplicate | Flag | PURGE
Linkedin Software Engineer Algorithm - 2of 2 votes
AnswersGenerate a random binary tree, with equal probability.
- pb August 30, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - -2of 2 votes
AnswersMedian of Stream of Running Integers
- anaghakr89 August 16, 2017 in United States
Note: The integers are in particular range from 1..n
The time complexity of the code should be o(n)| Report Duplicate | Flag | PURGE
Google Software Engineer - 1of 1 vote
AnswersIf you are given 2 infinitely large integers in the form of strings, given the length of the string, find the product of the two integers.
- Anon August 15, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 0of 0 votes
AnswersHow will you multiply two infinitely large integers.
- Anon August 15, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 0of 0 votes
AnswerSolve the 24 Game
- aonecoding August 14, 2017 in United States| Report Duplicate | Flag | PURGE
Twitter Software Engineer Algorithm - 0of 0 votes
AnswerProblem:
- yangsuli August 13, 2017
Given 100 stones, two players alternate to take stones out. One can take any number from 1 to 15; however, one cannot take any number that was already taken. If in the end of the game, there is k stones left, but 1 - k have all been previously taken, one can take k stones. The one who takes the last stone wins. How can the first player always win?
My Idea
Use recursion (or dynamic programming). Base case 1, where player 1 has a winning strategy.
Reducing: for n stones left, if palyer 1 takes m1 stones, he has to ensure that for all options player 2 has (m2), he has a winning strategy. Thus the problem is reduced to (n - m1 - m2).
Follow Up Question:
If one uses DP, the potential number of tables to be filled is large (2^15), since the available options left depend on the history, which has 2^15 possibilities.
How can you optimize?
I don't have a great answer to the follow up question。。。| Report Duplicate | Flag | PURGE
Huawei Software Engineer Dynamic Programming - 3of 3 votes
AnswersRound4
- aonecoding August 09, 2017 in United States
Starting from num = 0, add 2^i (where i can be any non-negative integer) to num until num == N. Print all paths of how num turns from 0 to N.
For example if N = 4,
Paths printed are [0,1,2,3,4], [0,1,2,4], [0,1,3,4], [0,2,4], [0,2,3,4], [0,4].
[0,2,4] is made from 0 + 2^1 + 2^1. [0,1,3,4] from 0 + 2^0 + 2^1 + 2^0| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersRound3
- aonecoding August 09, 2017 in United States
For N light bulbs, implement two methods
I. isOn(int i) - find if the ith bulb is on or off.
II. toggle(int start, int end)| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm