## Recent Interview Questions

- 0of 0 votes

Answers0 change to 01,1 change to 10.

- ajay.raj December 22, 2017 in United States

Line 0 is 0, the first line is 01, the second line is 0110, the third line 01101001. . . Keep asking what is the vale at kth row and jth col| Report Duplicate | Flag | PURGE

Google SDE1 - 0of 0 votes

AnswersAssuming your budget is N, you need to buy a rectangular land. Give a matrix of land prices and ask what is the largest area available for buying land. Land prices must be non-negative. For example, the budget is 11.

`1 2 3 1 0 1 4 2 1 9 10 4 The output should be. 1 2 3 0 1 4`

Such a matrix, because 1 +2 +3 +0 +1 +4 = 11. And the largest area.

- ajay.raj December 22, 2017 in United States| Report Duplicate | Flag | PURGE

Google SDE1 - 1of 1 vote

AnswersThe grid is n by m. Each cell contains a unique number on it. Maga is at the left-top and wants to go to right-bottom. But there is a condition. Maga can go through only two way - right and down. And the path of your move is called the nodes you have passed through over them. The path is called the most beautiful if the following condition is satisfied: The sorted of the path has to be lexicographic smallest as possible as. Output the most beautiful path for given grid.

Input:

In the first line you are given two numbers: the dimensions of grid - n and m. The next n lines contains m numbers. Each number is unique.

Output:

Output the most beautiful path.`4 2 3 1`

Return 1 2 4

- ajay.raj December 22, 2017 in United States

There are 2 ways to reach at (2,2) cell. The pathes are 4, 3, 1 or 4, 2, 1 respectively. So The most beautiful of them is 4, 2, 1 because if looking the sorted of them it looks like these : 1, 3, 4 and 1, 2, 4 respectively. So 1, 2, 4 is lexicographic smaller than the other. So the ans is 1 2 4.| Report Duplicate | Flag | PURGE

Google SDE1 - 0of 0 votes

AnswersThere is a door to enter a restroom. Once you enter the restroom there are N toilets starting from 1, 2,... to N. The toilet which is near to entry door starts from 1 and then it serially goes till N. You can use toilet based on below conditions:

- anjali306 December 21, 2017 in United States

1. If none of the toilets are occupied then choose one which is nearest to the entry door(which is toilet#1).

2. If at least one toilet is occupied then choose that unoccupied toilet which is farthest from the occupied ones.

3. If there are more than one unoccupied toilets whose farthest distance from the occupied ones are same then choose one which is near to the door.

For example:

Let's say there are 5 toilets.

-> First person comes and occupies toilet#1(Based on rule#1).

-> 2nd person comes and occupies toilet#5(Based on rule#2).

-> 3rd person comes and occupies toilet#3(Based on rule#2). Note that the farthest distance would have been formed when the new person would have occupied toilet#2(or toilet#4) but with that, the distance between toilet#2(unoccupied) and toilet#1(occupied) would be just 1.

-> 4th person comes in. Now from toilet#1 to toilet#5, only toilet#2 & toilet#4 are unoccupied. Now there are 2 toilets(#2 & #4) whose farthest distance from unoccupied ones are equal(=1). So rule#3 will apply and toilet#2 will be occupied.

You have to find the sum of those toilet numbers which are occupied.

So in above example after 4th person, toilet numbers which are occupied are #1, #5, #3 & #2.

So answer would be 1+5+3+2 = 11.| Report Duplicate | Flag | PURGE

Amazon - 0of 0 votes

AnswersTwo binary tree, to determine whether the two trees "similar", similar refers to the corresponding node in each tree in the left child and right child can be the same or in the opposite order, such as the following two trees, D, E where DE And DE can also be DE and ED, BC is the same, but the parent child relationship must be the same.

Followup is if left and right can be the same how to do,

- ajay.raj December 21, 2017 in United States`A / \ B C / \ D E A / \ C B / \ D E`

| Report Duplicate | Flag | PURGE

Google SDE1 - 0of 0 votes

AnswersFind valid bracket from provided string. Only { [ ( are involved as brackets. A valid bracket contains with a enclose companion.

- Sat December 19, 2017 in India

Example: {} is valid, [[] Invalid

Input: {[()]}[]() Result: Valid

Input: {}[]()( Result: Invalid| Report Duplicate | Flag | PURGE

abc Senior Software Development Engineer - 0of 0 votes

Answerswindows customer toll free number ― 1800-653-1176 ― microsoft windows customer service number

- contribuor December 19, 2017 in United States| Report Duplicate | Flag | PURGE

- 0of 0 votes

Answerswindows technical support number ― 1800-653-1176 ― microsoft windows technical support number ― G/Irux

- contribuor December 19, 2017 in United States| Report Duplicate | Flag | PURGE

Absolute Softech Ltd abc - 0of 0 votes

AnswersContact: 1-800-653-1176 Norton™ Activation Customer Care Number

- contribuor December 19, 2017 in United States| Report Duplicate | Flag | PURGE

- 1of 1 vote

Answersgiven n player competition, a bool canbeat (int a, int b) can return a whether beat b. Asked to return a sequence, the sequence only requires two adjacent to the front beat behind. Example, 1 beat 2, 2 beat 3, 3 beat 4, 3 beat 1, 4 beat 1 You can return "1234", that is, although 3,4 can beat 1, but not adjacent does not matter

- ajay.raj December 19, 2017 in United States| Report Duplicate | Flag | PURGE

Google SDE1 - 0of 0 votes

AnswersGive a two-dimensional array, which represents the value of the jump to the four directions, asked whether from the upper left corner to the lower right corner, follow up the shortest distance

- ajay.raj December 19, 2017 in United States| Report Duplicate | Flag | PURGE

Google SDE1 - 0of 0 votes

AnswersTo A and B two list, B is A shuffle obtained, find the mapping used shuffle,

- ajay.raj December 19, 2017 in United States

To be able to handle duplicate elements.

Follow-up: Requirements space O (1),| Report Duplicate | Flag | PURGE

Google SDE1 - 0of 0 votes

Answerslist, push is pushed to the head, pop return each element with the same probability. If you push a sorted list into it, how to pop a sorted list out. Follow-up, asked if pop is from head, and push each element with the same probability in any position, how pop a sorted list out?

- ajay.raj December 17, 2017 in United States| Report Duplicate | Flag | PURGE

Google SDE1 - 0of 0 votes

AnswersDetermines whether two strings containing backspace keys are the same.

- ajay.raj December 17, 2017 in United States| Report Duplicate | Flag | PURGE

Google SDE1 - 0of 0 votes

AnswersA car can receive two instructions A and R. A moves forward for a second and then doubles in speed. R stopped and then reversed. Given a String composed of AR, find where will the car stop.

- ajay.raj December 17, 2017 in United States

Follow-up, given the location if the final stop, find the instruction string.| Report Duplicate | Flag | PURGE

Google SDE1 - 1of 1 vote

Answersclass EncodingChecker {

- ajay.raj December 17, 2017 in United States

EncodingChecker (String pattern) {...} // constructor

boolean isEncoded (String s) {...} // for any string s, check whether s is encoded from pattern, see below

}

pattern = 'abcabc'

s = '123123' -> True

= 'cbzabc' -> False

= 'xyzxyz' -> True

Second question: If the pattern is not one but one million, how to write isEncoded?| Report Duplicate | Flag | PURGE

Google SDE1 - 1of 1 vote

AnswersPrint words in order which are occurring once in huge document. The RAM size 100MB and file size 10 GB.

- Optimist December 16, 2017 in India

Example: I am good. You are good.

Answer : I am You are

Note : It's not datastructure problem where we can simply make use of LinkedHashMap. The file size is going to be huge.| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersFind the maximum sum of subset of size K in an array

- ajay.raj December 16, 2017 in United States| Report Duplicate | Flag | PURGE

Facebook Developer Program Engineer - 1of 1 vote

AnswersDefine a flight class, the flight has four attributes start, end, start time and arrival time,

- ajay.raj December 16, 2017 in United States

There is also a list of strings, represents there is a crew member on that site.

given a list of flights, along with the list of strings mentioned above, asking if the flight crew availability is available for all flights.

example: flight 1 {A, B, 3, 10}, flight 2 {A, C, 1, 7}, flight 3 {C, D, 9, 11} crew member list {"A", "A"} Then return true because flight 3 can take off as flight 1 and flight 2 take off first, then flight 2 descends to bring flight crew A to C.

If flight 3 is {C, D, 6, 12} then return false because no flight crew member is in C at time 6.| Report Duplicate | Flag | PURGE

Google SDE1 - 0of 0 votes

AnswersGiven an array (may have negative num) and an integer(may be negative), find the smallest subarray whose sum is >= the given integer.

- ajay.raj December 16, 2017 in United States

int[] nums2 = {5,4,-8,16};

int x=10;

return 1, because 16 >= x

try to solve it in o(n) time

public static int miniSubArrayLen(int[] nums, int s) {| Report Duplicate | Flag | PURGE

Facebook SDE1 - 0of 0 votes

AnswersSo recently to someone I know a question was ask how do you rotate a 2 dimensional array? He was asked to white board it. He could get diagram the problem but had trouble coding it.

- glen@jetsoftdev.com December 15, 2017 in United States

This is not an easy answer because equal dimensional array are easy but require you know the trip that you divide the x and y dimension and then do four swapping rotation around the corners. Not equal X,Y are much harder. When I heard this question, I could get the equal dimensions done in an hour or two in a compiler. It took me two days to get the total program working. Here is the code:

{

#include <stdio.h>

int main()

{

#define xsize 4

#define ysize 8

int matrix[ysize*xsize] ;

typedef enum rotation

{

CW0,

CW90,

CW180,

CW270,

CCW0,

CCW90,

CCW180,

CCW270,

DONE0

} RotationTypes;

RotationTypes DesiredRotation = CW270;

#define min(a,b) ( (a) < (b) ? a : b)

int x,y,r,swap0, swap1,rotx,roty, rotidx;

//walk through every possibily

for (DesiredRotation = CW0; DesiredRotation <= DONE0 ; DesiredRotation++)

{

for (y=0;y<ysize;y++)

{

for (x=0;x<xsize;x++)

{

matrix[(y*xsize)+x] = y + x*10;

//print the base rotation for references

if ( DesiredRotation == CW0

|| DesiredRotation == CCW0

|| DesiredRotation == DONE0)

printf("%d ", matrix[(y*xsize)+x]);

}

if ( DesiredRotation == CW0

|| DesiredRotation == CCW0

|| DesiredRotation == DONE0)

printf("\n");

}

if ( DesiredRotation == CW0

|| DesiredRotation == CCW0

|| DesiredRotation == DONE0)

printf("\n");

//flips are generally more effeicient than rotation

//bu doing flips you only have to do one 90 degree

// type of rotation. flips work on uneven dimeions

if (DesiredRotation != CCW90 && DesiredRotation != CW270)

{

//horiztonal flip

for (y=0;y<ysize;y++)

{

for (x=0; x<xsize/2;x++)

{

swap0 = matrix[(y*xsize)+x];

matrix[(y*xsize)+x] = matrix[(y*xsize)+((xsize-1)-x)] ;

matrix[(y*xsize)+((xsize-1)-x)] = swap0;

}

}

//vertical flip

for (y=0;y<ysize/2;y++)

{

for (x=0; x<xsize;x++)

{

swap0 = matrix[(y*xsize)+x];

matrix[(y*xsize)+x] = matrix[(((ysize-1)-y)*xsize)+x] ;

matrix[(((ysize-1)-y)*xsize)+x] = swap0;

}

}

}

if (DesiredRotation != CW0

&& DesiredRotation != CW180

&& DesiredRotation != CCW0

&& DesiredRotation != CCW180

&& DesiredRotation != DONE0)

{

//do one CCW90 rotation which is the same as CW270

//if would be more effiecient to hard code every

//different combination but no way to make it elegant

int sqsize=min(ysize,xsize);

//first do the inplace square part because it is very efficient

for (y=0;y<sqsize/2;y++)

{

for (x=0;x<(sqsize+1)/2;x++)

{

rotx = x;

roty = y;

//store the top, left

int swap0 = matrix[(y*xsize)+x];

//rotate into top left from top right

matrix[(y*xsize)+x] = matrix[(x*xsize)+((sqsize-1)-y)];

//rotate into top right from bottom right

matrix[(x*xsize)+((sqsize-1)-y)] = matrix[(((sqsize-1)-y)*xsize)+((sqsize-1)-x)];

//rotate into bottom right from bottom left

matrix[(((sqsize-1)-y)*xsize)+((sqsize-1)-x)] = matrix[(((sqsize-1)-x)*xsize)+y];

//into into bottom left from original top left

matrix[(((sqsize-1)-x)*xsize)+y] = swap0;

}

}

//now the challenge is what to do with unequal array left overs

//we chose to hardcode inserting rotation and swapping until done

//we have to do two different sets of code if height is

//greater than width

if (ysize>xsize)

{

int rotinc=0;

int baseptr = sqsize*sqsize;

int rowsize = xsize;

for (x=xsize-1;x>=0;x--)

{

for (y=sqsize;y<ysize;y++)

{

//find where the extra non square starts after

//the sqaure part of the arrary

int rotptr = baseptr+((y-sqsize)*rowsize)+x;

//store it for later insertion

swap0 = matrix[rotptr];

//find where in the new dimensions

//the rotation from the end of the square should

//go

int swapptr = (((xsize-1)-x)*ysize)+y;

//swap upswards to make room for the

//insertion

while (rotptr>swapptr)

{

matrix[rotptr] = matrix[rotptr-1];

rotptr--;

}

//insert the rotation at the proper place

//which is now free

matrix[swapptr] = swap0;

}

//we have done one row so increase where the

//base pointer will be for the next time

baseptr+=ysize-sqsize;

//because we did one rotation the remaining rows

//are one rotation smaller

rowsize--;

}

}

//width is bigger than height

if (xsize>ysize)

{

int rotinc=0;

int rowsize = xsize;

for (x=sqsize;x<xsize;x++)

{

//insert happen at the begging of the array for

//this sizing

int swapptr = 0;

for (y=0;y<ysize;y++)

{

//find the rotation at the end of each row

int rotptr = rotinc+(y*rowsize)+sqsize;

//store it for latter use

swap0 = matrix[rotptr];

//swap upwards to made room for the insertion

while (rotptr>swapptr)

{

matrix[rotptr] = matrix[rotptr-1];

rotptr--;

}

//issert the rotation at the begining of the

//array

matrix[swapptr] = swap0;

//increasement the point

swapptr++;

}

//we have done one row so need to increase

//our start posiiton

rotinc+=ysize;

//we have done one row. the remain is one row smaller

rowsize--;

}

}

//print out the rotated and maybe flipped new array

for (x=0;x<xsize;x++)

{

for (y=0;y<ysize;y++)

{

printf("%d ", matrix[(x*ysize)+y]);

}

printf("\n");

}

} else {

//printout the vertical flipped only array

if (DesiredRotation != CW0

&& DesiredRotation != CCW0

&& DesiredRotation != DONE0)

{

for (y=0;y<ysize;y++)

{

for (x=0;x<xsize;x++)

{

printf("%d ", matrix[(y*xsize)+x]);

}

printf("\n");

}

}

}

printf("\n");

}

return 0;

}

}| Report Duplicate | Flag | PURGE

.Net/C# - 0of 0 votes

AnswersCreate a SQL-like language parser that manipulates directories and files (The compiler/parser may be created in any other language).

To summarize, I want you to create a "file and directory manipulation language" with the following rules/syntax (you may create another commands):

CREATE DIR <path>

CREATE FILE <name> IN <path> [WITH <data>]

'WITH' insert the <data> in the file on the fly, but it's optional

GET DATA FROM <path/to/file>

Examples on how this language may be used:`import FDML ex = "Hey guys" data = FDML.get('GET DATA FROM "./path/to/file"'); FDML.statement("""CREATE DIR "./imgs"; CREATE FILE "test.txt" IN "./path/to/dir""") FDML.statement('CREATE FILE "welcome.txt" IN "./path/to/dir" WITH "{}"'.format(ex)) print(data)`

Or those commands can be run in a shell:

- lopogax December 15, 2017 in United States

> fdml "CREATE DIR './dir'"

> /dir was created!| Report Duplicate | Flag | PURGE

unknown Software Engineer parsing - 3of 3 votes

AnswersDropBox Dec 2017

- aonecoding December 15, 2017 in United States

Congrats to Brian landing @DropBox

Dropbox always has the most responsive HR and gives review on the interview within a week. The canteen is also one of the best in Bay Area.

Phone：

LC: game of life

What if the board is huge?

Store in disk

with bitmap

Load into memory, process and write to disk row by row

Visit AONECODE.COM for private lessons by FB, Google and Uber engineers

Our ONE TO ONE class offers

SYSTEM DESIGN Courses (highly recommended for candidates of FB, LinkedIn, Amazon, Google & Uber etc.)

ALGORITHMS (conquer DP, Greedy, Graph, Advanced Algos & Clean Coding),

latest interview questions sorted by companies,

mock interviews.

Members get hired from G, U, FB, Amazon, LinkedIn, MS and other top-tier companies after weeks of training.

Email us aonecoding@gmail.com with any questions. Thanks!

Onsite：

Round 1：

Given an array of byte and a file name, find if the array of byte is in file.

Solution: Rolling hash

Round 2：

Given an Iterator of some photo with IDs, find the top K most hit photo IDs.

Follow up: What if the input is from a stream? When iterator reaches the end, moments later new hits can be added to the iterator. Modify code for this scenario.

Lunch was great.

Then came a demo round. Discussed Dropbox Paper| Report Duplicate | Flag | PURGE

Dropbox Software Engineer - 0of 0 votes

AnswersYou are given a binary tree in which each node contains an integer value.

- ajay.raj December 15, 2017 in United States

Find the number of paths that sum to a given value.

The path does not need to start at root, but need to end at a leaf, and it must go downwards (traveling only from parent nodes to child nodes).

/**

* Definition for a binary tree node.

* public class TreeNode {

* int val;

* TreeNode left;

* TreeNode right;

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

* }

*/

class Solution {

public int pathSum(TreeNode root, int sum) {

}

}| Report Duplicate | Flag | PURGE

Google SDE1 - 0of 0 votes

AnswersGive a bunch of rectangles, randomly return a point within the rectangle, the probability to be proportional to the size of the rectangle.

- ajay.raj December 15, 2017 in United States

Follow up1: If you want to repeatedly call the function to generate random points how to do.

Follow up2: If the rectangles overlap how to do?| Report Duplicate | Flag | PURGE

Google SDE1 - 0of 0 votes

AnswersA smart-set is a set of distinct numbers in which all the elements have the same number of 1s in their binary form. The set of all smallest elements from each smart-set

- aspi December 15, 2017 in United States

that can be formed from a given array of distinct positive numbers is known as the smartest-set.

So given an array of distinct numbers, outline the elements of the smartest-set in ascending sorted order.

Input Format

The first line of input consists of an integer t. This is the number of test cases. For each test case,

the first line of input contains an integer n. Here n is the number of elements in the array. The next line contains n space separated distinct integers which are the elements

of the array.

Output Format

The output will space separated integer elements of the smartest-set in ascending order.

Constraints

0 < t < 1000 (This is the number of test cases

2 < n < 10000 (This is the number of integer elements of the array)

1 < Xi < 100000 (This is the size of each element of the array)

Python coding| Report Duplicate | Flag | PURGE

Python - 0of 0 votes

AnswersAs clients search for the compressed posting of companions movement. Who is very certain a genuine proprietor is sign through the record as the trickster after hacking one's record peep to the next record and recover access to that one too. There are sure things that should be seen through various verticals and same applies for this situation too. Facebook support number is the best way get this doubt solved.

- lindaallen024 December 14, 2017| Report Duplicate | Flag | PURGE

- 0of 0 votes

AnswersWe have 4 swimmers A,B,C,D with their records in 4 types of swimming races i.e Freestyle, Frontstroke , Backstroke and Butterffly respectively.The data is given as 4 arrays each for one player where each element in the array represents their time in particular race.

- Abhishek_108 December 14, 2017 in India

We have to select these players for a relay race such that the total time is minimum.| Report Duplicate | Flag | PURGE

Motorola SDE1 - 1of 1 vote

AnswersGiven an extremely large file that contains parenthesis, how would you say that the parenthesis are balanced?

The file cannot fit in the memory. How would you process the file and how would you store the intermediate results.

Walk me through the entire algorithm.

- CodeNinja December 14, 2017 in United States`Examples: {[()]}, {[](){}}, [] are some valid examples.`

| Report Duplicate | Flag | PURGE

Google Software Engineer Stacks - 0of 0 votes

AnswersMagical binary strings are non-empty binary strings if the following two conditions are true:

- ajay.raj December 14, 2017 in United States

The number of 0's is equal to the number of 1's.

For every prefix of the binary string, the number of 1's should not be less than the number of 0's.

A magical string can contain multiple magical substrings. If two consecutive substrings are magical, then we can swap the substrings as long as the resulting string is still a magical string. Given a magical binary string, str, perform zero or more swap operations on its consecutive magical substrings such that the resulting string is aslexicographically large as possible. Two substrings are considered to be consecutive if the last character of the first substring occurs exactly one index before the first character of the second substring.

-----

Input Format

a single binary string, str.

Constraints

It is guaranteed that str is a binary string of 1's and 0's only.

1 ≤ length(str) ≤ 50

It is guaranteed that str is a magical string.

Output Format

Find a string denoting the lexicographically largest magical string that can be formed from str.

Sample Input 0

11011000

Sample output

11100100

Explanation of sample

Given the magical string str = 11011000, we can choose two consecutive magical substrings, 1100 and 10, to swap such that the resultant string, str' = 11100100, is the lexicographically largest possible magical string possible. Thus, we return the value of str', which is 11100100, as our answer.| Report Duplicate | Flag | PURGE

SDE1

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window