## Recent Interview Questions

- 0of 0 votes
An art museum has the shape of a square and it contains N*N rooms. Some of the rooms are open and they contain art, other rooms are locked. There are guards in some of the open rooms. The museum's administration is afraid of a break in and they would like to evaluate how well the guards are positioned in the open rooms inside the museum. Precisely, they wish to know for each open room what is the distance to the colest guard. This distance is the min number of rooms a guard needs to pass through to reach that room. The guards can only move through the open rooms North, South, East and West and they can't leave the museum.

'.' is for open room 'G' is for open room where a guard is '#' is for a locked room Noboday can enter or pass through thesse rooms.

- 0of 0 votes
How to annihilate twisted FB issues via Facebook Customer Service 1-877-470-3053?

- 0of 0 votes
How To Install FB Messenger On I-Phone? Get Facebook Customer Service?

- 0of 0 votes
How to Do Business On FB? Grab Facebook Customer Service 1-877-470-3053

- 0of 0 votes
How to Edit Temporary Profile Photo? Get Facebook Customer Service 1-877-470-3053

- 0of 0 votes
How to use Facebook for promotion via Facebook Customer Service 1-877-470-3053?

- 0of 0 votes
There is a ball on the nth stairs, and it wants to get to the ground(level 0). There are some sticky stairs, and once the ball lands on the sticky stair, it is stuck and can never move.

During odd turns, you can jump down 1, 2, or 4 stairs. During even turns, you can jump down 1, 3, 4 stairs.

Return the number of ways you can get to ground.

- 0of 0 votes
Print 0 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1

Follow the below rules

Intialiazation should not be done by 0 i.e. I= 0 should not be done

Only one time a loop or tertiary conditions or increment or decrement should be done

No nested loops or nested conditions only 1 loop or 1 condition should be used

Ex if() or for {}

One loop and 1 condition can't be use.. u can use either this or that

- 0of 0 votes
A special number is defined as a number where, in binary notation,

a. has only set bits (OR)

b. all set bits are followed by unset bits (OR)

c. the sequence formed by count of the number of set bits separated by any number of unset bits is a contiguous subsequence of the sequence of natural numbers.

2, 3, 11271 and 15667135 are special numbers because their binary represenation is 10, 11, 10110000000111 and 111011110000111110111111 respectively.

2 is a special number because of condition (b).

3 is a special number because of condition (a).

11271 is a special number because its binary representation is 10110000000111 because of condition (c). The sequence of the count of number of set bits separated by a unset bits is 1, 2 and 3. This is clearly a continguous subsequence of the natural numbers.

Similarly, 15667135 is a special number. (The sequence is 3,4, 5 and 6.)

So, given two integers n and m where n <= m, find out the number of special numbers between n and m inclusive.

Input Format:

The first line of input contains an integer T where T is the number of test cases. Then T lines follow containing two space separated integers n and m where n <= m.

Output Format:

For each test case, output, in different lines, a single integer P where P is the number of special numbers between the range specified.

Constraints:

1 <= T <= 1000

1 <= n <= 10^6

1 <= m <= 10^6

n <= m

Sample Input:

4

2 10

11 15

20 30

2 100

Sample Output:

6

4

5

43

- 0of 0 votes
Maximum Sum of Building Speed

You are the king of Pensville where you have 2N workers.

All workers will be grouped in association of size 2,so a total of N associations have to be formed.

The building speed of the ith worker is Ai.

To make an association, you pick up 2N workers. Let the minimum building speed between both workers be x, then the association has the resultant building speed x.

You have to print the maximum value possible of the sum of building speeds of N associations if you make the associations optimally.

Constraints

1≤N≤5∗10 ^4

1≤Ai≤10^4

Input

First line contains an integer N, representing the number of associations to be made.

Next line contains 2N space separated integers, denoting the building speeds of 2N workers.

Output

Print the maximum value possible of the sum of building speeds of all the associations.

Sample Input

2

1 3 1 2

Sample Output

3

- 0of 0 votes
I have applied for Software Engineer at a startup company in India, I have asked the following question.

You are building an application with ORM model say django, you have set of models, urls. Let's say an user is hitting api /user/account/profile/xxx/yyy like this. You have to check whether user has permission to access or not. If user has access to /user/ then he has access to the whole URL, like wise if he has access to /user/account/ he has access to whole URL. User table looks like below and it has a field called prefix which contains URL prefix of that particular user.

Users

userid | prefix | username | firstname | lastname

1 /user/ lokesh1729 lokesh sanapalli

2 /user/account lokesh1729 lokesh sanapalli

What is the most efficient way to check if a particular user has access to an API or not???

I gave a brute-force approach that first we will check if he has access to /user/ then /user/account then /user/account/profile and so on, if he has access to a prefix and we will process the request.

He is not satisfied with the answer. Can anyone tell me what might be the answer for this???

- 1of 1 vote
The time taken by ith person to complete a task is Ki minutes.

A company wants to finish N tasks given K persons each if their given time. Find minimum time to complete N tasks using K persons. There is no waiting time between the tasks switching. Persons can start their tasks simultaneously.

For N=3 and K=2,

Input:

3 2

1

2

Output:

2

Explanation:

Person 1 will start task 1 at t=0. Person 2 will start task 2 at t=0.

At t=1, Person 1 will switch to 3rd task finishing its first task.

By the end of 2 minutes, all 3 tasks will be finished. So, minimum time taken is 3 minutes.

- 0of 0 votes
in a NxN matrix, a robot is moving in a direction. there are some blocks where it can change its direction(left/right/uturn/up/down). find an optimal path to go between 2 points..

travel rule :

1) robot must move in right direction from the starting point...

2) robot move in a clock wise direction

3) some square road block is there, where robot can not pass( can be 1x1 or 3x3 .. size is odd no square) but can go adjacent to wall in clockwise direction.

4) 1 cell = 1 step

plz help me with the algo.. or pesudo code.. how to determine the moving direction ( right or moving clockwise)

- 0of 0 votes
2d array with max 1's

- 0of 0 votes
You are in the upper left corner, sitting in a boat, you want to reach to the lower right corner, but the matrix has a certain height at each location (i, j), and the boat can only go through the cell with water in it, looking for the earliest time that the boat can reach from the upper left corner coordinates (0,0) to the lower right coordinates (n-1, n-1). Each day, water goes up by one height unit

- 0of 0 votes
Choose a random point from one single rectangle.

Choose a random point from multiple rectangles, if there isno overlapping among them.

Choose a random point from multiple rectangles, if there isoverlapping among them.

- 0of 0 votes
Given a string of size n consisting of 0s and/or 1s.you have to perform k queries and there are two types of queries possible.

"1"(without quotes): Print length of the longest substring with all '1'.

"2 X"(without quotes): where X is an Integer between 1 to n.In this query, you will change character at Xth position to '1' (it is possible that the character at ith position was already '1')

Input Format:

First Line of input contains n and k, where n is string length and k is the number of queries.

Next line contains a string of 0's and/or 1's of length n.

Each of next k lines contains query of any one type (i.e 1 or 2).

Output Format: For each query of type 1, print in new line the maximum size of subarray with all 1's.

Example Input:

5 7

00000

1

2 3

1

2 5

1

2 4

1

Example Output:

0

1

1

3

- 0of 0 votes
Lets say we have to find a tallest line of the horizon from a given 2D array of the preprocessed image. The line starts at left most column of the Martrix and end at right most column of the matrix. To calculate the line you can only move left to right to 3 position, diagonally up , horizontally right and diagonally right i.e from a[i][j] you can move to a[i-1][j+1], a[i][j+1] and a[i+1][j+1].

When moving to the right we need to pick the highest value in the cell . We will do this for very row in column 0 i.e a[0][j] then we will pick the smallest value of the path we have got. The ans will the smallest of the all values we got from traversing all the path

I know this bit vague and I had hard time understanding the question but this what I understood

Lets say we have 3*3 array {{5,4,8}, {1,5,9}, {2,6,10}} . Now if we start from a[1][0] the possible path we can have

1 -> 6 -> 10 as we have to pick the highest value . Once we have this path we pick the smallest value on this path which is 1 . We repeat this for all rows in a[i][0] then among all those values pick the smallest one

Find the best line from the matrix.

I said we can do BFS to find best path but interviewer said time complexity of that is too high, need to do better than that.

Time complexity for BFS I think is Rows * 3^Colms as from any given cell we have 3 options to go to right (please confirm this as I not sure about it)

- 0of 0 votes
Say you have an array for which the ith element is the price of a given stock on day i, you can buy stock at any day, but can only buy once a day, but if you sell the stock, you must sell all of them at once.

Seeking maximum profit

public int maxProfit(int[] prices) {

- 0of 0 votes
given a html file, compare if two html file show the same contents.

Eg.

<html> <body> <p> H <i> ello </ i> </ p> <body> </ html> is typed as "Hello \ n" without regard to <i> , "\ n" because of <p>

follow up: what if the string is very long

- 0of 0 votes
given a binary matrix of 01s, each time you click a point (i, j), the bit of the same row and column are all flipped.

check if a matrix can be all 0s after many of this operation.

- 0of 0 votes
design a sweeping robot, there are three functions:

move (), which returns boolean value

turn_left (k), which make robot turns left k times.

turn_right (k), which make robot turns right k times.

Design an algorithm to make robot clean up all room. Timecomplexity, linear in term of room space.

- 0of 0 votes
Given a binary tree, print the path that has the maximum path sum.

For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need to go through the root. the node val may be negative one`For example: Given the below binary tree, 1 / \ 2 3 Return 2-1-3. -1 / \ -2 3 \ -1 Return 3. public List<Integer> findMaxPath(TreeNode root){ } /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */`

- 0of 0 votes
Given a graph, each node may have one or more children, updating the value of a child node is not less than the parent node.

follow-up each child node may have one or more parent nodes,

- 1of 1 vote
Given a function that returns 0 and 1 with a probability of fifty percent, use this function to generate a random number between a and b with uniform distribution

- 0of 0 votes
Judge if two arrays has the same pattern,

The definition is the relative relationship between each number and other numbers are the same, such as 132, 354, the first number is less than the second, the first less than the third, the second is greater than the third,

So is the same,

132,352 is not the same, because the first 132 is less than the third, the first 352 is greater than the second,

follow up, the array may concern duplicates

- 2of 2 votes
Congrats on aonecode.com member V.S. on the offer from Microsoft and thanks for sharing with us the experience.

Coding Question 1 - Find all the paths between two nodes

Coding question 2 : Max sum in adjacent sub array

Design Question - Design a ticketing System

Design Question 2 - Design a system which allows multiple agents to read different data from same tables. Latency should be low. Algorithm should rank agents through some logic and assigned work according to that so that each agents are reading different set of rows from same table. Scale it for 20 million active agents .

Follow up - If Data Sharding is allowed, what will be the Shard Id and how the partition will look like? How your system will respond if there are agents which are also writing at same time. Consistency should be given high preference over availability.

Looking for coaching on interview prep?

Visit AONECODE.COM for ONE-TO-ONE private lessons by FB, Google and Uber engineers!

Customized course covers

System Design (for candidates of FB, LinkedIn, AMZ, Google & Uber etc)

Algorithms (DP, Greedy, Graph etc. every aspect you need in a coding interview & Clean Coding)

Interview questions sorted by companies

Mock Interviews

Our members got into G, U, FB, Amazon, LinkedIn, MS and other top-tier companies after weeks of training.

Feel free to email us aonecoding@gmail.com with any questions. Thanks!

- 1of 1 vote
A city bus station information, example, bus No. 1 stops at abcd station, bus No. 2 stops at cefg station. Then a-d you only need to take No. 1, thus return 1, a-g is 2, because you need to transfer at station c,

ask for a minimum bus you need to take to reach to another station. You can design any data structures.

- 0of 0 votes
class QueryVector

{

QueryVector(vector values)

{

// Implement

}

vector GetIndices(list filters)

{

// Implement

}

}

Say for example vector is like

{“an”, “apple”, “day”, “keeps”, “doctor”, “away”, “apple”, “iphones”, “cool”, “doctor”, “recommends”}.

GetIndices(“apple”) should return (1, 6)

GetIndices(“doctor”,”cool”) should return (4,8,9)

GetIndices(“random”) should return empty vector ()

GetIndices(“random”,”keeps”,”day”,”doctor”) should return empty vector (2,3,4,9)

Important:

1. There can be millions of values in the input vector of string

2. GetIndices can be called repeatedly and it should be optimized

3. How storage optimization is considered and bitmaps etc are used.

- 0of 0 votes
Please Looked my website www.couponseller.in And Tell me What should i change On my website