## Recent Interview Questions

- 0of 0 votes

AnswersGiven an array of 100 numbers, find the (unique set) of duplicate values.

- jkatzwhitew January 29, 2019 in United States| Report Duplicate | Flag | PURGE

Linode Python Developer Python - 0of 0 votes

AnswersFind all of the different permutations of a string without using any built-in permutation functions. Your answer should not contain duplicates.

- jkatzwhitew January 29, 2019 in United States| Report Duplicate | Flag | PURGE

Linode Python Developer Python - 0of 0 votes

AnswersYou have oracle database table , and AURORA AWS table with same fields , write a java lambda function to migrate data from oracle table to aurora. Also it should be realtime, if a new record is added to oracle it should update aurora db table as well.

- Brucewratner January 29, 2019 in United States| Report Duplicate | Flag | PURGE

Amazon Backend Developer Java - 0of 0 votes

AnswersHello All ,

- ramaselva24 January 27, 2019 in United States

I would like to understand onsite interview experience for amazon lab126 in device os team for QAE role .

Could you please any one share your experience ? I also want to know any system design question will come and detail about your experience as well ?| Report Duplicate | Flag | PURGE

- 0of 0 votes

AnswersGiven an array of edges between any two points in 2 dimensional space. A single edge is represented by the co-ordinates of two points it is connecting for example (2,3),(4,5) represents and edge connecting points (2,3) and (4,5).Find out the total number of squares possible if all edges are parallel to X or Y axis.

- jadonv January 26, 2019 in United States

NOTE : Include overlapping squares, squares having one side in common and squares contained within another square. Co-ordinates can have float values.

Example below -

I have considered a very simple input and output combination to keep it short.

Input

{

(0,0),(0,3)

(0,0),(3,0)

(0,3),(3,3)

(3,0),(3,3)

}

Output : 1

Possible Approach : Create a map as below -

Key(Slope of Edge in Degrees) - Value(Array of Edges)

0 - {(0,0),(3,0)},{(0,3),(3,3)}

90 - {(0,0),(0,3)},{(3,0),(3,3)}

While inserting edges in the map, make sure the edges are sorted by max(x1,x2) first and then max(y1,y2).

Pick 2 edges from one slope let's say slope 0, then pick 2 edges from slope 90 and see if square is formed or not. If square not formed, then look at next 2 edges of slope 90 and so on.

Sorting here is an expensive operation.

Please share any better solutions.| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 0of 0 votes

AnswersYou have a bunch of shops. Each shops sells a bundle of chocolates at a fixed cost. You are given an amount and the price sheet of shops. Find the maximum number of chocolates that you can buy with the amount.

`Int Calculate(Int Amount, []Int Quantities, []Int Cost) { // Implement }`

Other points: (1) You cannot use 'sort' (2) The costliest shop need not sell the maximum number of chocolates. (3) Tricky cases exist. For example: Shop 1 sells 10 chocolates in a 10 $ bundle. Shop 2 sells 9 chocolates in a 1$ bundle. If you have 10$ in your hand, Here the maximum number of chocolates that you can buy is not 10 but 90.

- git January 24, 2019 in United States| Report Duplicate | Flag | PURGE

Numeric Backend Developer Algorithm - 1of 1 vote

AnswersGiven a directed graph and a node , find the shortest cycle in a graph with given node .

- saurabh January 23, 2019 in India| Report Duplicate | Flag | PURGE

Google Software Developer Coding - 0of 0 votes

AnswersGiven a

`struct drop{ float x_cordinate; float radius; }`

Return the number of calls that the function Drop() that returns a drop object, needs to be called so that the interval [0, 1) is covered. For each drop object the range covered are values on a line considering x_cordinate as center and radius as the length added on both sides of the x_cordinate on that line?

`int numCalls(const function<drop> Drop){ drop firstDrop = Drop(); // Code from here }`

For example, if the first Drop() call returns drop object drop.location as 0.5 (considering points on a 1d axis) and drop.radius as 0.2, then the interval covered is [0.3, 0.7). So how many calls need to be made to ensure the interval [0, 1) is covered. The location and radius can map to any real value.

- rahul January 21, 2019 in United States| Report Duplicate | Flag | PURGE

Facebook Software Engineer Intern - 2of 2 votes

AnswersGiven a list of arrays of time intervals, write a function that calculates the total amount of time covered by the intervals.

- aonecoding4 January 19, 2019 in United States

For example:

input = [(1,4), (2,3)]

return 3

input = [(4,6), (1,2)]

return 3

input = {{1,4}, {6,8}, {2,4}, {7,9}, {10, 15}}

return 11| Report Duplicate | Flag | PURGE

Facebook Software Engineer - 0of 0 votes

AnswersYou are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

- User042891 January 17, 2019 in United States| Report Duplicate | Flag | PURGE

Facebook Intern - 0of 0 votes

Answersgiven an array representing a non-negative integer (ex: 123 represented as [1,2,3]), return the next integer (output: [1,2,4]).

- User042891 January 17, 2019 in United States

run through all edge cases (ex: [9,9,9,9,9,9,9,9] etc)| Report Duplicate | Flag | PURGE

Facebook Intern - -1of 1 vote

AnswersComplicated problem statement but was asked to implement binary search

- User042891 January 17, 2019 in United States| Report Duplicate | Flag | PURGE

Facebook Intern - -1of 1 vote

AnswersSparse Scalar vector dot product.

- User042891 January 17, 2019 in United States

in less than O(n)| Report Duplicate | Flag | PURGE

Facebook Intern - 0of 0 votes

AnswersWrite a uniform random function generator from 1 to n, given a uniform random Boolean generator, which return true or false for a given number randomly.

- SRC January 17, 2019 in United States| Report Duplicate | Flag | PURGE

- 0of 0 votes

AnswersGiven a graph in which there is an edge between (u,v) if gcd(u,v)>g . Given queries of u,v find if a path from u,v exists

- manaranjanfav January 17, 2019 in United States| Report Duplicate | Flag | PURGE

Algorithm - 1of 1 vote

AnswersWrite a new data structure, "Dictionary with Last"

- Coder January 15, 2019 in United States

Methods:

set(key, value) - adds an element to the dictionary

get(key) - returns the element

delete(key) - removes the element

last() - returns the last key that was added or read.

In case a key was removed, last will return the previous key in order.| Report Duplicate | Flag | PURGE

Facebook Software Engineer Data Structures - 1of 1 vote

AnswersGiven a grid M x N cells having weight in each cell(any integer),

- keviIma January 15, 2019 in United States

For every path from TOP-LEFT to BOTTOM-RIGHT, find the minimum weight you come across.(Minimum per path.)

Now from all those minimum weights, find the Maximum.

You can move in all 9 directions.

Is this a trick question?| Report Duplicate | Flag | PURGE

Amazon - 1of 1 vote

AnswersGiven an integer S, you have to count the total number of integral solutions of the equation a+b^2+c^3+d^4<=S, such that 0<=a,b,c,d<=10000 and 0<S<10^15

- Ankita January 13, 2019 in United States

Edit: Here value can be less than or equal to S, so if input S= 2 ,then output=12

i.e we can consider 0,0,0,1 and 0,0,0,0 etc also as sum will be less than S(i.e 2)| Report Duplicate | Flag | PURGE

SDE1 Algorithm - 0of 0 votes

AnswersGiven two strings Y and Z , return True if y beats z or z beats y .

- saurabh January 10, 2019 in India

Beating Criteria : for i in [1,N] y[i]>=z[i] , if this condition is true for any of permutations of y for any of the permutations of z .| Report Duplicate | Flag | PURGE

Directi Software Engineer Algorithm - 2of 2 votes

AnswersGet the sum of all prime numbers up to N. primeSum(N).

- aonecoding4 January 07, 2019 in United States

Follow-up: If primeSum(N) is frequently called, how to optimize it.| Report Duplicate | Flag | PURGE

Amazon - -5of 5 votes

AnswersFind a pair that equals to the given target from the list of given two lists.

- sarunreddy82 January 07, 2019 in United States

example:

input:

target = 7

list1= [[1,2],[2,4[,[3,6]]

list2 = [[1,2]]

Output:[[2,1]]

Explanation: There are only three combinations [1,1],[2,1] and [3,1], which use a total of 4,6, 8 respectively. Since 6 is the largest use that does not exceed 7, [2,1] is the only optimal pair.

Example 2:

Input :

target = 10

list1 = [[1,3],[2,5],[3,7],[4,10]]

list2 = [[1,2],[2,3],[3,4],[4,5]]

Output;

[[2,4],[3,2]]| Report Duplicate | Flag | PURGE

Amazon Arrays - 0of 0 votes

AnswerHow to divide a circular array into k group of contiguous element such that difference between maximum sum and minimum sum is minimum. Each group have contiguous element of array. For e.g If the array is as follow. [6 13 10 2] and k=2 then o/p should be 18(6+10+2)-13=5. As array is circular 6,10,2 are contiguous element of array.

- Himanshu Singh January 05, 2019 in India

For e.g If the array is as follow. [6 13 2 10] and k=2 then o/p should be 16(6+10)-15(13+2)=1. As array is circular 6,10 are contiguous element of array.

For e.g If the array is as follow. [100 92 133 201 34 34 34 94 108] and k=4 then group as follow 208(108,100), 225(92,133), (201), 196(34,34,34,94) so 225-196=29| Report Duplicate | Flag | PURGE

Samsung Software Developer Algorithm - 0of 0 votes

AnswersPrroblem: write an algorithm to calculate the minimum cost to add new roads between the cities such that all the cities are accessible from each other

int numTotalAvailableCities = 6;

int numTotalAvailableRoads = 3;

int[,] roadsAvailable = { { 1, 4 }, { 4, 5 }, { 2, 3 } };

int[,] costNewRoadsToConstruct = { { 1, 2,5 }, { 1,3,10 }, {1,6,2} ,{ 5, 6, 5 } };

int numNewRoadsConstruct = 4;

- sunil.sebastian January 05, 2019 in United States`public class MinimumCostToConstructNewRoad { public static int getMinimumCostToConstruct(int numTotalAvailableCities, int numTotalAvailableRoads, int[,] roadsAvailable, int numNewRoadsConstruct, int[,] costNewRoadsConstruct) { int totalCost = 0; bool[] Visited = new bool[numTotalAvailableCities]; int[] Keys = new int[numTotalAvailableCities]; int[] Parent = new int[numTotalAvailableCities]; int[,] AdjMatrix = GetAdjecencyMatrix(roadsAvailable, costNewRoadsConstruct, numTotalAvailableCities); for (int i=0;i< numTotalAvailableCities;i++) { Keys[i] = Int32.MaxValue; } Keys[0] = 0; Parent[0] = -1; for(int i=0;i< numTotalAvailableCities-1;i++) { var u = FindMin(Visited, Keys); Visited[u] = true; for(int v=0;v< numTotalAvailableCities;v++) { if(Visited[v]==false && AdjMatrix[u, v]!=Int32.MaxValue && AdjMatrix[u,v]<Keys[v]) { Parent[v] = u; Keys[v] = AdjMatrix[u, v]; } } } for(int i=1;i< numTotalAvailableCities;i++) { totalCost = totalCost + AdjMatrix[Parent[i], i]; } return totalCost; } private static int FindMin(bool[] Visited, int[] Keys) { int min = Int32.MaxValue; int index = -1; for (int i = 0; i < Keys.Length; i++) { if (Visited[i] == false && Keys[i] < min) { min = Keys[i]; index = i; } } return index; } private static int[,] GetAdjecencyMatrix(int[,] roadsAvailable, int[,] costNewRoadsConstruct,int numTotalAvailableCities) { int[,] AdjMatrix = new int[numTotalAvailableCities, numTotalAvailableCities]; for (int i = 0; i < numTotalAvailableCities; i++) { for (int j = 0; j < numTotalAvailableCities; j++) { AdjMatrix[i, j] = Int32.MaxValue; } } int count = 0; for (int i = 0; i < roadsAvailable.GetLength(0); i++) { int start = roadsAvailable[i, count]-1; int end = roadsAvailable[i,count+1]-1; AdjMatrix[start, end] = 0; } for (int i = 0; i < costNewRoadsConstruct.GetLength(0); i++) { int start = costNewRoadsConstruct[i, count]-1; int end = costNewRoadsConstruct[i, count+1]-1; int cost= costNewRoadsConstruct[i, count + 2]; AdjMatrix[start, end] = cost; } return AdjMatrix; } }`

| Report Duplicate | Flag | PURGE

Amazon SDE-2 Data Structures - 0of 0 votes

AnswersMaximum Pairs

You are given N pencils. You have to make pairs of pencils.

The condition for making pairs is:

If(a,b) is any pair of pencils then b >= 2 * a. Here a and b are the sizes of pencils.

Now you have to find out the number of such pairs and the number of pencils which could not be paired with any pencils.

Note:

You need to pair the pencils in such a manner that the maximum number of pairs are formed.

Input Format:

The first line consists of number of test case T.

Each test case consist of:

- First line consists of a single integer N.

- Second line consists of N space-separated integers denoting the size of pencils Si.

Output Format:

For each test case, print two space-separated integers, first denoting the number of pairs formed and second denoting the number of unpaired pencils.

Answer for each test case should come in a new line.

Constraints

1<T<=10

1<=N<=10^5

0<=Si<=10^5

Sample Input

2

5

1 2 3 4 5

4

1 2 4 4

Sample Output

2 1

2 0

Explanation

In the first test case:-

we can form the following pairs:

(1, 3), (2, 4) and 5 remains unpaired hence maximum pairs are 2

In second test case:-

(1, 4), (2, 4) are two pairs hence no pencil left unpaired

- Karan Khosla January 04, 2019 in United States for 4`public class Test { public static void main(String[] args) { } static int[] solve(int[] arr) { // the value at first index of array to be returned is number of pairs // formed and value at second index is unpaired swords. } }`

| Report Duplicate | Flag | PURGE

Java Developer Java - 0of 0 votes

AnswersGiven a target number and a single number, write a program to find the shortest path to calculate the target number by applying "+-*/" operations to the single number. No parentheses. For example, if we have target number=26 and single number=3 return 3 * 3 * 3 - 3 / 3.

- morfysster January 03, 2019 in United States| Report Duplicate | Flag | PURGE

Algorithm - 2of 2 votes

AnswersGiven a Start Node and an End Node in a graph report if they are “necessarily connected”. This means that all paths from the start node lead to the end node. Report true all paths from start node lead to end node and false if at least one path does not lead to the end node. This is a directed graph which can have cycles

- nikki December 31, 2018 in United States

Does anyone know how to solve this? I had it in my interview at Google in CA and I still cant solve it| Report Duplicate | Flag | PURGE

Google SDE1 Algorithm - 0of 0 votes

Answershow would you debug a tablet with a part of its touch screen is broken.

- rakshith18n December 31, 2018 in United States| Report Duplicate | Flag | PURGE

Amazon SDET - 0of 0 votes

AnswersGiven an arbitrary tree remove nodes which have data value 0.

- keviIma December 31, 2018 in United States

As it stats arbitrary tree, I assumed n-ary tree.| Report Duplicate | Flag | PURGE

Facebook Software Engineer - 0of 0 votes

AnswersDesign a Google Sheet System?

- xyz December 28, 2018 in United States

Where do you store the data? sql or nosql

How do you maintain concurrency?

How do you display it in frontend, which can be inline editable?| Report Duplicate | Flag | PURGE

rallyhealth Backend Developer System Design - 0of 0 votes

Answers* Build Offices

- keviIma December 26, 2018 in United States

A company wants to develop an office park in an area that has been divided up into a grid where each cell represents a potential building lot. The goal is for the furthest of all lots to be as near as 1 possible to an office building. Determine the building placement to minimize the distance the 0 most distant lot is from an office building. Movement is restricted to horizontal and vertical, i.e. diagonal movement is not allowed.

For example, there are n = 3 office buildings to build on a grid that is w = 4 lots wide and h = 4 lots high. An optimal grid placement sets any lot within two units distance of an office building. In the distance grid below, offices are cells at distance 0.

1 0 1 2

2 1 2 1

1 0 1 0

2 1 2 1

That represents one optimal solution among several, this array rotated for example.

The function must return an integer that denotes the maximal value among shortest distances to the closest office for each cell.

findMinDistance has the following parameter(s): w: an integer, the width of the grid h: an integer, the height of the grid n: an integer, the number of buildings to place

Constraints:

wxh <= 28| Report Duplicate | Flag | PURGE

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

Open Chat in New Window