## Software Engineer Interview Questions

- 2of 2 votes
Congrats on aonecode member A.P. for signing the offer with FB! Thanks for sharing the experience with us.

phone:

postorder tree traversal recursive -> iterative

add two binary number

on-site:

1 ring buffer

2 merge intervals

3 Leetcode alien dictionary

4.sort list of words

- 1of 1 vote
Airbnb: Design webbrowser back button

Your web browser supports will support three actions: back, forward and open. The init webpage is “about:blank”.

Given a sequence of commands. Return the result page.

- 0of 0 votes
find the sum of bit wise OR of minimum and Maximum element of all the subsets whose length is greater than 2 of the given of set.

for ex:-

{1,2,3} is set

then possible subsets of length is{ 1,2},{1,3},{2,3}{1,2,3} answer 1|2 +1|3 +2|3 +1|3=12

- 0of 0 votes
The wildcard regex can include the characters * and + .

‘+’ – matches any single character or empty character!

‘*’ – Matches any sequence of characters (including the empty sequence) For example,

Text = "baaabab":

regex = "ba*a++", output : true

regex = "ba*a+", output : true

regex = "a*ab", output : false

//empty string

Text=""

Regex= "+" , output : true

- 0of 0 votes
I was asked this question in a recent interview for a startup.

We have coffee vending machine with 3 buttons which can dispense 4oz, 7oz and 13oz of coffee.

Given a cup and the min and max amount(oz) of coffee it should fill. determine if the coffee vending machine can satisfy the condition.

The buttons can be pressed as many times as possible to fill the cup. Coffee shouldn't overflow..

- 1of 1 vote
AWS phone interview

Find the left view of binary tree

1

/ \

2 3

/\ \

4 5 6

/ /

7 8

/

9

return [1, 2, 4, 7, 9]

- -2of 2 votes
If b == “1”:

quit()

- 1of 1 vote
Write a method that can take in an unordered list of airport pairs visited during a trip, and return the list in order:

Unordered: ("ITO", "KOA"), ("ANC", "SEA"), ("LGA", "CDG"), ("KOA", "LGA"), ("PDX", "ITO"), ("SEA", "PDX")

Ordered: ("ANC", "SEA"), ("SEA", "PDX"), ("PDX", "ITO"), ("ITO", "KOA"), ("KOA", "LGA"), ("LGA", "CDG")

- 2of 2 votes
April Google Interview 1/4

A = a+b-c-a-b-c-a-b (Tree)

B = b+a+c+a+b-c+b (Tree)

is A equal to B

- 3of 3 votes
April Google Interview 4/4

Build HTML Reverser

Given

<A>(hello)(<P>ab</P>)(<S>hi</S>)</A>

Return

<A>(<S>ih</S>)(<P>ba</P>)(olleh)</A>

- 2of 2 votes
April Google Interview 3/4

Maze

N,M array

Level 1 0,0 to N-1,M-1 => Path exsits?

Level 2 if path exists then print path

Level 3 if path exists then print min cost path

Level 4 O(nm log mn) using Priority Queue.

- 3of 3 votes
April Google Interview 2/4

Count Number Given Array

Level1 Unsorted Array [1, 3, 2, 1, 2 ,3 , 4, 10]

Find occurrence of 1

Level 2 Sorted Array

Find occurrence of 1

- 0of 0 votes
/**

* Definition for a binary tree node.

* public class TreeNode {

* int val;

* TreeNode left;

* TreeNode right;

* TreeNode(int x) { val = x; }

* }

*/`Find the largest duplicate subtree in a binary tree For example, 1 / \ 2 3 / / \ 4 2 4 / 4 The following are two duplicate subtrees: 2 / 4 and 4`

but the former is the largest, thus return the root of the first subtree

- 0of 0 votes
Given a target string, an input request replaces the word after the given index a->b such as:

Target string: "Hello world!"

Input:{s:0, a:Hello b: Goodbye}

Output:"Goodbye world!".

The requirement is that input be given to several words that need to be changed at one time: {{s:0,a:Hello,b:Goodbye},{s:11,a:!,b:?},{s:6 a: World,b:friend}}

And each modified index is based on the original unmodified target string so the end result is

"Goodbye friend?"

- 0of 0 votes
given a n-ary tree, find the total distance from this node to any other nodes

class TreeNode {

int val;

List<TreeNode> children;

TreeNode(int val) {

this.val = val;

children = new ArrayList<>();

}

}

public int findDistance(TreeNode root, TreeNode node) {

}

- 0of 0 votes
Design a Twitter-like topic system so that the most popular topics can be retrieved from the system. A post can have one or more topics and these topics can be shared by multiple posts. (hint: thinking of scalability)

- 1of 1 vote
Assume courses labeled by their index in an array. Given a list of pairs where the first element represents a prerequisite course required for the second course, derive an ordered list of courses.

- 0of 0 votes
For a given set of non-negative integers get the number of subsets that add up to a target value k.

- 0of 0 votes
For a given array of integers compute the maximum sum of any range in the array. Then modify the function to find maximum product (note the effect of negatives on max product).

- 0of 0 votes
Write a function to compute n^k. (don't forget negative exponents)

- 0of 0 votes
Print (or return) the longest movie title found by successively matching the last and first words in each title, joining to form new titles, given a file containing a list of movie titles.

For example: 'OF MICE AND MEN' and 'MEN IN BLACK' join to form 'OF MICE AND MEN IN BLACK'.

You could further join 'OF MICE AND MEN IN BLACK' wth 'BLACK MASS' to form 'OF MICE AND MEN IN BLACK MASS'.

The longest title I found (at 143 characters is): WENT TO CONEY ISLAND ON A MISSION FROM GOD BE BACK BY FIVE WIVES THREE SECRETARIES AND ME WITHOUT YOU CANT TAKE IT WITH YOU WERE NEVER LOVELIER

- 0of 0 votes
Given a bar chart which the heights of bars are notated as an array of positive integers. Rectangles can be formed in areas covered by one or more bars. Find the largest rectangle.

- 5of 5 votes
FB On-site March

Q: Find number of Islands.

XXXOO

OOOXX

XXOOX

Return 3 islands.

1 1 1OO

OOO2 2

3 3OO 2

Followup: If the board is too big to fit in memory, how to get the number?

- 0of 0 votes
.

- 0of 0 votes
Given two sets of intervals such as {[1, 2], [4, 8]} and {[2, 5]}. Find their union {[1, 8]} for the two intervals.

- 0of 0 votes
Design a dictionary which words are grouped by the same characters. For example, dog and god are in the same group. And how to make it scalable to handle a huge number of words?

- 3of 3 votes
Find the median of a very big array of integer. Only iterator of array is given

- 3of 3 votes
Google

Given two lowercase strings, S1 and S2, sort S1 in same order as S2.

If a character in S1 doesn't exist in S2, put them at the end. If S1 is "program" and S2 is "grapo", then return "grrapom".

- 3of 3 votes
Twitter

Count number of each character in a string and print out the counts from highest to lowest.

- 0of 0 votes
find max path sum in DAG, weight can be negative