## Software Engineer Interview Questions

- 0of 0 votes
Given a array of integers there is one that is repeated several time. How would you compute the length of the sequence of repeated elements.

Assuming the initial array is sorted can you do better than O(n) both for spatial and temporal cost?

- 2of 2 votes
FB on-site two weeks ago last round of coding . (This problem is also in the internal question bank of G.)

There is a robot in a room. The initial location of the robot is unknown. The shape or area of the room is unknown.

You have a remote that could walk the robot into any of the four directions - up, left, down or right.

Here is the move method: boolean move(int direction), direction: 0, 1, 2, 3. If the robot hits the wall, the method returns false.

Otherwise returns true and the robot moves on to the direction given.

Find out the area of the room.

e.g.

X

XXX X

XXXXX 'X' marks the floor plan of the room.

A room like such has an area of 10.

- 0of 0 votes
Edward is organizing a meeting and has to order lunch for everyone in the team. To make his task simpler he has prepared two lists. The first list has pairs of team members and their preferred cuisine types. Each team member either has a preference for a particular cuisine or does not have any particular preference and likes all cuisines. The second one contains a list of lunch options along with the cuisine type to which it belongs. Each lunch option belongs to only one cuisine type.

Write an algorithm that outputs a list of all possible pairs of team members along with lunch option they would enjoy. There can be no, one or more entries for a team member in the output list depending on how many lunch options satisfy their choice of cuisine(s).

Input

The input to the function/method consists of four arguments – lunchMenuPairs, representing a list containing pairs of lunch option and its associated cuisine type; teamCuisinePreference, representing a list containing pairs of team members and their cuisine preferences.

Output

Return a list representing all possible pairs of team members and lunch options they would enjoy.

Note

If a team member does not have a particular preference and likes all cuisines, then the preference is specified as a "*" in the teamCuisinePreference list.

Order of rows in the returned list does not matter.

Example

Input:

lunchMenuPairs:

[[Pizza, Italian],

[Curry, Indian],

[Masala, Indian]]

teamCuisinePreference:

[[Jose, Italian],

[John, Indian],

[Sarah, Thai],

[Mary, *]]

Output:

[[John, Curry],

[John,Masala],

[Jose, Pizza],

[Mary, Curry],

[Mary, Masala],

[Mary, Pizza]]

- 0of 0 votes
Given a 2D character array of size NxN. Find if there is a path from the cell 'R' to the cell 'T'. You can go left, right, up, down from a cell and you cannot pass through any cell marked with 'X'.

Example input:

X__R_X

X_XXX_

______

_XX_XX

XT__X_

Output: true

- 0of 0 votes
Print all permutations of a given string.

- 0of 0 votes
Implement power function. The function should take two numbers as input (e.g. 2,3) and return 8 as output

See link below for hints and answer https://baquerrizvinotes.blogspot.in/2017/05/how-to-crack-amazoncom-technical.html

- 1of 1 vote
You have a array with integers:

`[ 1, -2, 0, 6, 2, -4, 6, 6 ]`

You need to write a function which will evenly return indexes of a max value in the array.

In the example below max value is 6, and its positions are 3, 6 and 7. So each run function should return random index from the set.

Try to implement with O(n) for computation and memory.

Try to reduce memory complexity to O(1).

- 0of 0 votes
You have a binary tree which consists of 0 or 1 in the way, that each node value is a LOGICAL AND between its children:

`0 / \ 0 1 / \ / \ 0 1 1 1`

You need to write a code, which will invert given LEAF and put tree in a correct state.

- 0of 0 votes
Given a binary tree of integers, write code to store the tree into a list of integers and recreate the original tree from a list of integers.

Here's what your method signatures should look like (in Java):

List<Integer> store(Node root)

Node restore(List<Integer> list)

Example Tree:

5

/ \

3 2

/ / \

1 6 1

- 0of 0 votes
Implement pow(x, n)

- 1of 1 vote
Pick three numbers a, b, c from an array of integers to get the maximum product a * b * c.

Began with the O(N^3) solution. Then the interviewer give clues on optimization by sorting the array.

- 0of 0 votes
Given a large file with sentences and query string, design a system (Class, data structs, functions, etc) and algorithm to return the smallest window (start and end offsets) in the input file where the query words (in any order) are seen in the text file. What is the time complexity?

- 1of 1 vote
Given an input string and a dictionary of words, find out if the input string can be segmented into a space-separated sequence of dictionary words.

Ex: "bedbathandbeyond" would be "bed bath and beyond" which are all dictionary words.

- 1of 1 vote
Generate a random 4-digit even number : the adjacent 2 digits must be different.

public int getNumber(){

}

- 0of 2 votes
Amazon SDE 2 On-site (1 of 4 Rounds)

In a file system stored a large amount of user’s browsing data, including the urls that the user visited. Design a function that outputs the longest common path of all the urls.

Having finished the code, I was asked to analyze the complexity.

- -1of 1 vote
Amazon SDE 2 On-site (4 of 4 Rounds)

Assume that there is an e-book application. For every book the sharable part of the book content cannot exceed 10% of the whole book. Design a module to decide whether the current part of content is sharable.

The description given is vague. I had to push him with questions to give the details.

At first I thought the problem was about strStr. But then the interviewer said that even if there are two paragraphs of the book content with the exact same texts, as long as they are not in the same place, they would be considered different content.

I then realized it’s a question about merging segments - have a helper to find each pair of start and end point of the input content (given multiple separated paragraphs). Then merge the intervals and see if they combined exceed 10% of the entire book.

The interviewer approved my solution and ask me to code it.

Overall I feel like that the Amazon SDE II Interview doesn’t focus on just algorithm. It’s more about problem solving in practice and then implement the only core function on whiteboard.

- 0of 0 votes
Design an electronic voting system for india , design its schema , scaling its working, failure conditions & optimization

- 0of 0 votes
find the isomorphic pairs of string !!

a string is said to be isomorphic if its each alphabets can be replaced by another alphabet

for ex "abca" and "zxyz" are isomorphic but "abca" and "pqrs" is not isomorphic

conditions :

1 - A character can be replaced by itself. for ex "abcd" and "pbfg" are isomorphic .

2- No two characters can be replaced by same character . for ex "abcd" and "bbcd" are not isomorphic .

- 0of 0 votes
Find the subarray within an array (containing at least TWO number) which has the largest sum.

For example, given the array [-2,-1,-3,-4,-1],

the contiguous subarray [-2,-1] has the largest sum = -3.

try to do it in O(n) time

Followup, if input is stream, how to solve it

public int maxSubArray(int[] nums) {}

- -1of 1 vote
Sorry had to remove this question

- 0of 0 votes
Write code for the following: given a text file containing this information (Date the customer is logged in, tab, customer id)

04/11/2017 /t 0003

04/12/2017 /t 0003

04/13/2017 /t 0004

04/13/2017 /t 0003

How to get the list of those customers that log in on three consecutive days.

- 0of 0 votes
OOPS: How to design Amazon locker? Provide code using OOP

- 0of 0 votes
How to merge two binary trees in place? (without creating a new node)

- 0of 0 votes
A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.

For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 1000010001 and contains two binary gaps: one of length 4 and one of length 3. The number 20 has binary representation 10100 and contains one binary gap of length 1. The number 15 has binary representation 1111 and has no binary gaps.

Write a function:

int solution(int N);

that, given a positive integer N, returns the length of its longest binary gap. The function should return 0 if N doesn't contain a binary gap.

For example, given N = 1041 the function should return 5, because N has binary representation 10000010001 and so its longest binary gap is of length 5.

Assume that:

N is an integer within the range [1..2,147,483,647].

Complexity:

expected worst-case time complexity is O(log(N));

expected worst-case space complexity is O(1).

- 0of 0 votes
Find two strings are meta string or not

for eg:-

Converse

Conserve

are meta strings because if we swap s and v in the string both string will become equal. If swapping of more than one pair can be done then it is not a meta string

- 0of 0 votes
Find the median of a bst in O(n) time and O(1) space

- 0of 0 votes
VMWare Standard Online Screen

3rd Question Given an array of strings and a long description about the formatting of IPv6 and IPv4 (it took me more than 5 minutes to read the description). Write a function to find if a string is IPv4 or IPv6 address or neither.

4th Question Given an integer array, whenever a duplicate number is found, you may increment it (++). Find the minimum sum of the numbers in the array by keep incrementing the dups until all the numbers are unique.

- 1of 1 vote
VMWare Standard Online Screen

The Online Assessment was called something like Life Cycle Challenge-qpan.

There are 4 questions in total given 60 minutes. The problem description was unexpectedly long that it takes 5 minutes just to read a question.

1st Question Design a function to create BST. Given an integer array, insert the integers into the binary search tree and print all the steps taken.

2nd Question Given an integer, print the index of all the positions in which the binary bit is 1 in order.

- 0of 0 votes
Given a count and maxvalue, write a program to return count number of unique random integers between 0 and maxvalue.

- 3of 3 votes
Facebook Senior Engineer On-site 2017

1st Round

Question 1: Binary tree to doubly linked list.

Question 2: Read 4 (Given the read4 API, read an entire file)

2nd Round

Culture fit. No coding.

3rd Round

Question: System Design POI (Point of Interest. Given a point, find things within a radius).

Lunch

4th Round

Question 1: Decode way

Question 2: Random max index

5th Round

Question: System design + component-wise design on download manager