## Software Engineer Interview Questions

- 0of 0 votes
Write code to find unmatched parentheses and return it in the below format:

((a) -> -10a1

(a)) -> 0a1-1

(((abc))((d))))) -> 000abc1100d111-1-1

- 0of 0 votes
Given an array of sorted integers and find the closest value to the given number. Array may contain duplicate values and negative numbers.

Example : Array : 2,5,6,7,8,8,9

Target number : 5

Output : 5

Target number : 11

Output : 9

Target Number : 4

Output : 5

- 0of 0 votes
Implement a trie tree which can add and search word, an extra "*" sign will also be considered, similar to Leetcode 211 but with "*"

'*' means any sequence of characters (including the empty sequence).

- 1of 3 votes
Congrats to aonecode's member F.L.

Got offers from - Youtube(G), LinkedIn, Airbnb, Square, Wish, Blend and NextDoor!

Thanks for sharing the interview experience with us.

Youtube Interview

- Phone: Find anagrams of string A from string B (sliding window)

- Phone: Find if two frames in a screen are equal. Frames may overlap. (equal method)

Onsite:

- LC41 first missing positive

- LC499+LC505 The maze

- LC161 one edit distance

- Similar to hangman but make guesses based on a dictionary.

Assume a dictionary has words - {house, morse, jesus} and ‘morse’ is the answer. If your first guess is ‘house’, output will be ‘_o_se’, which indicates 3 letters are correct. (Here the arrangement of letters does not matter. Your guess can be ‘co’ and if answer is ‘ok’ then the output is gonna be ‘_o’ which indicates letter ‘o’ in answer. )

Try to get the answer with minimum guesses.

(Interviewer expects pre-processing the dictionary. Key: letter; Value: frequency. Begin with combinations of most frequent letters first)

- 1of 3 votes
Congrats to F.L.

Got offers from - Youtube(G), LinkedIn, Airbnb, Square, Wish, Blend and NextDoor!

Thanks for sharing the interview experience with us.

LinkedIn

Phone:

- Questions from LC tagged LinkedIn.

Onsite:

- Get sqrt(x). Output a floored integer if result is not a perfect square. sqrt(18) = 4

- Implement BST, insert, delete, search.

- Design a dashboard for service logs stats (sort and aggregate). Scale from 1 to more machines. Discuss async and realtime as different scenarios.

- 2of 2 votes
Facebook

-Phone: LC304 & longest arithmetic sequence. Return the sequence.

- 0of 0 votes
Given a string S(a data structure) that contains only square brackets, convert it to an array that stores arrays in the following format: [positionOpeningBracket, positionClosingBracket, nestedDataStructure]. Example: https://i.imgur.com/vZhlZdr.png

`def parser(S): #whatever... print(r) parser("[[]][]") #output: [[0,3,[1,2,null]], [4, 5, null]]`

- 3of 3 votes
Question 1.

You are given a string composed of uppercase English letters (‘A’ through ‘Z’).

Set of letters (‘A’, ‘E’, ‘I’, ‘O’, ‘U’) are called vowels. Other letters are called consonants.

We define foo value of a string as number of pairs of exactly same consecutive vowel letters.

For example,

Ex.1: BCDEEIOU - This has a foo value of 1 (because of EE). Note that although I is next to E, and O is next to I, and U is next to O, they aren’t exactly same neighbours, so they don’t contribute to foo value

Ex.2: BCDEEEIOU - This has foo value of 2. Because of first pair of EE and immediately next pair of EE

Ex.3: ABCDEFG - This has foo value of 0. There are no consecutive vowels

Ex.4: ABEUUOUOO - This has foo value of 2, because of UU and OO

You are given 2 inputs, N and K.

How many strings of length N can you form such that they all have foo value of K?

Let’s assume the constraints as:

1<=N<=15

0<=K<N

- 0of 0 votes
Given a sorted list of integers, square the elements and give the output in sorted order.

- 0of 0 votes
Find the distance between the farthest two elements in a binary tree.

- 0of 0 votes
`A text file contains {candidateID,voterID} details of an ongoing voting. Read this file in real time and report top 5 candidates. Also report a fraud if a Voter tries to vote twice or try to vote more then one candidate. Assume that the database is offline.`

- 0of 0 votes
Given list of line segments({x_start, y_start}, {x_end, y_end}) find out the maximum number of points they intersect. (interviewer said, he can make it simpler by assuming only vertical or horizontal lines with no overlapping lines)

Givenen tree in which each node has (or grows) exactly 4 children with values (2, 2.5, 8, 50) plus the value of its parent node. Find out the least K values.

e,g, k = 5, node with value 2, 2.5, 4, 4.5, 6

- 0of 0 votes
List of processes with start time, end time and bandwidth. Find the maximum bandwidth for the list.

2. Given N teams which need to play each other exactly once but at most once in one day, output the game schedule.

- 0of 0 votes
Snake 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.

- 0of 0 votes
Longest substring palindrome

(interview looking for n^2 or less solution)

- 1of 1 vote
Airbnb Online Assessment Paginate List

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

- 2of 2 votes
Find the indices of all anagrams of a given word in a another word.

For example: Find the indices of all the anagrams of AB in ABCDBACDAB (Answer: 0, 4, 8)

- 2of 2 votes
Amazon OA2

Implement a round robin scheduler.

Each process has an arrival time Atime[i], execute time Etime[i].

Q is the maximum time that a process gets executed in its turn. If the process isn't finished after q, it waits till the next round.

Output average wait time for the processes.

- 1of 1 vote
Given 2 words, return true if second word has a substring that is also an anagram of word 1.

LGE , GOOGLE- True

GEO, GOOGLE - False

- 0of 0 votes
Given two list of unsorted intervals V1 and V2 write 2 functions 'OR ' and 'And' to return a new list

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

- 0of 0 votes
Check if two DOM Trees have the same text.

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)

- 1of 1 vote
create a class of integer collection,

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

- 0of 0 votes
Lonely Pixel

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))

- 0of 0 votes
Find max size of contiguous shape below, where X represents a shape and . is empty:

.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

- 0of 0 votes
There are billions and billions of stars in the universe. Which data structure would you use to answer the query

"Give me the k stars nearest to Earth".

Expectation is to come up with the list of parameters/fields in the data structure as well.

- 0of 0 votes
How would you design the "call logs" for a mobile phone ? Be as efficient as possible.

- 0of 0 votes
Given a 2D matrix A of size m x n, m > 0, n > 0 such that A[i][j] <= A[i][j + 1] and A[i][j] <= A[i + 1][j].

Write a C/C++/Java function to get the k-th smallest element from this matrix.

- 0of 0 votes
Inserting dashes between two odd numbers and star between two even numbers

- 2of 2 votes
Print Common Suffix In Strings

Ex: cornfiled , Exfiled --- field

- 0of 0 votes
Given an unsorted array. for example [2, 3, 1, 4, 5].

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.