## SDE-2 Interview Questions

- 0of 0 votes

AnswerGiven a text file - find out all the unique words and display the frequency of each word in descending order.

- Ankit May 31, 2021 in India| Report Duplicate | Flag | PURGE

Kasheruka SDE-2 Problem Solving - 0of 0 votes

AnswersGiven a input string 'Hello World' and a input reference String, give count of each character (from refString) in the given string

- Ankit May 31, 2021 in India

Eg inputString: "Hello World Please", refString: "Help"

Output: H: 1, e: 3, l: 4, p: 1| Report Duplicate | Flag | PURGE

Kasheruka SDE-2 Problem Solving - 0of 0 votes

AnswersELK related questions especially on optimizing logging

- Mayank Dubey May 19, 2021 in India for Java| Report Duplicate | Flag | PURGE

Kasheruka SDE-2 - 0of 0 votes

AnswersDesign a Nearby shops features for online map service provider.

- Mayank Dubey May 19, 2021 in India for Java| Report Duplicate | Flag | PURGE

Kasheruka SDE-2 - 0of 0 votes

AnswersDesign a system to find top 10 sold products for an online website at any point of time for last 15 minutes.

- Mayank Dubey May 19, 2021 in India for Java

Which data structure & algorithm would be the best to design such kind of systems?| Report Duplicate | Flag | PURGE

Kasheruka SDE-2 Algorithm - 0of 0 votes

AnswersYou are given a directed cyclic graph represented by an adjacency matrix. The graph has at least one terminal node (i.e. the node with no outgoing edges).

Each edge of the graph is assigned a positive integer representing a probability of taking this edge. E.g. if you have 3 outgoing edges with numbers 3, 2, and 4, this means that the prob. of taking these edges are: 3/9, 2/9 and 4/9, respectively.

You need to find the probability of reaching each terminal node from the starting node 0.

Example:

adjacency matrix 5x5:`m = {{0 1 0 0 1}, {0 0 3 2 0}, {4 0 0 1 0}, {0 0 0 0 0}, {0 0 0 0 0}}`

so we have two terminal nodes here: 3 and 4

- pavel.emeliyanenko@toptal.com May 11, 2021 in United States

we can take the following paths:

0 -> 1 -> 3 = probability: 1/2*2/5 = 1/5

0 -> 1 -> 2 -> 3 = probability: 1/2*3/5*1/5 = 3/50

0 -> 1 -> 2 -> 0 -> 1 -> 3 ... and so on

or to the node 4:

0 -> 4: probability: 1/2

0 -> 1 -> 2 -> 0 -> 4: probability 1/2*3/5*4/5*1/2 = 3/25

and so on, summing up probabilities of all possible paths we get:

total probability to reach node 3: 13/38

total probability to reach node 4: 25/38| Report Duplicate | Flag | PURGE

Microsoft SDE-2 Algorithm - 1of 1 vote

Answersdesign an ip blocking system

- nitinthakur5654 March 05, 2021 in India| Report Duplicate | Flag | PURGE

Amazon SDE-2 design - 0of 0 votes

AnswersGiven an n-ary tree and some queries for the tree, in every query you’ll be given a node you are supposed to print preorder traversal of the subtree rooted at that node.

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 3of 3 votes

AnswersYou have an array of numbers. You have to give the range in which each number is the maximum element. For Example, If array is 1, 5, 4, 3, 6 The output would be

- neer.1304 July 12, 2020 in United States

1 [1, 1]

5 [1, 4]

4 [3, 4]

3 [4, 4]

6 [1, 5]| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswerGiven an array of billion of numbers. Billions of queries are generated with parameters as starting and an ending index. Both these indices lie within that array. Find the maximum number between these two indices in less than O(N)

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersMultiply two numbers without using * and only be using bitwise operations

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersDisplay nodes of a tree in level order using DFS

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersImplement a deque using stacks

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersGiven the entire dictionary of English words, what data structure will you use to efficiently store and match the custom regex string like "D*sk", where * represents any single alphabet, and return the list of matched words?

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswerGiven a skewed tree, an insect is sitting at the root of the tree at t = 0min, every minute insect steps down in the tree, find the probability of the insect being at any node at t = infinity. Once I came up with a solution various other complexities has been added to the problem such as: What if the tree is binary tree (written code for this) What if three is n-ary What if it is now a directed acyclic graph Handle cases that there can be more than one entry point There can be more that one way to reach a node

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersGiven a binary tree of numbers and a search number has given, find out first occurence of that number and smallest distance from root node. if you have given k search numbers find their occurence and nearest from root node in a single walk.

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersGiven a string of numbers put commas so that it become readable like million trillion thousands. eg 1010503 ===> 1,010,503

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersGiven an array of 0s and 1s. find maximum no of consecutive 1s. If you have given chance to flip a bit to 1 such that it maximises the consecutive 1s. find out that flipped bit and after flipping that bit maximum no of consecutive 1s. Above question but you have options to flip k bits.

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersDesign a system which will keep track of product and its inventory count. The service will expose two api incrCnt(int prodId, int cnt) and decrCnt(int prodId, int cnt). Which db would you use ? How will you handle hot products ?

- neer.1304 July 01, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Software Design - 0of 0 votes

AnswerDesign a system in which read a file which has data and operation to be performed give a line by line. Ex a=5, next line b= 10, next line a*b. This design extended to support float, doubles, boolean, vector and complex numbers. Like if the file has a=5+i8, then how you handle such scenarios. How you will store and process data.

- neer.1304 June 08, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Software Design - 1of 1 vote

AnswersDesign content ingestion system

- kumar June 03, 2020 in India| Report Duplicate | Flag | PURGE

Amazon SDE-2 System Design - 0of 0 votes

AnswersYou are given 2 arrays: one representing the time people arrive at a door and other representing the direction they want to go(in or out) You have to find at what time each person will use the door provided no 2 people can use the door at the same time. Constraints: the door starts with ‘in’ position, in case of a conflict(2 or more people trying to use the door at the same time), the direction previously used holds precedence. If there is no conflict whoever comes first uses the door. Also if no one uses the door, it reverts back to the starting ‘in’ position. Should be linear time complexity.

- neer.1304 April 21, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 1of 1 vote

AnswersA startup website has a lot of real-time traffic . I want to see the real-time view (refreshed every 1 min) of top 20 users by hit count within last 10 mins. Full distributed system, I have to resolve all the concurrency issues.

- acharyashailendra1 December 22, 2019 in India| Report Duplicate | Flag | PURGE

Amazon SDE-2 - 1of 1 vote

AnswersI was asked this during my onsite google interview but was unable to come up with an optimization for it. Here is the question:

- Jaysun October 26, 2019 in United States

There's a list of (x,y) points and a method getCircle with the following signature:

/**

* Given three points returns a circle (Radius, and center) such that all three points lie in its circumference

* or it returns null if no such circle is possible.

*/

Circle getCircle(point1, point2, point3);

getCircle method is already implemented and given to you as a black box. The problems asks you to find the Circle with most points in its perimeter.

The obvious answer is to get all possible triplets of points and find all possible circles and keep track of which one appears most often O(n^3) . Any ideas on how to further optimize this?| Report Duplicate | Flag | PURGE

Google SDE-2 Algorithm - 0of 0 votes

AnswersThere are cards and each card has an identity. e.g. HC1 has ID 1, this ID also represents the cost of the card. Your sister already have some cards and you want to gift her cards which she do not have already. Program is to return the max number of cards you can buy for her.

- acharyashailendra1 September 19, 2019 in India

Constraint : You have amount d, and want to buy as many distinct card as you can.

e.g. Sister Cards = [2, 3, 5], D : 7 Card you buy : 1, 4

Output : 2| Report Duplicate | Flag | PURGE

SDE-2 - 0of 0 votes

AnswersYou have been given a special and normal status of alphabets.

- acharyashailendra1 September 19, 2019 in India

e.g. “01111001111111111011111111” represents “abcdefghijklmnopqrstuvwxyz”. Here 0 represents normal character and 1 represents special character.

Given an Input String S and a number k, find the maximum continuous sub array with maximum k number of number elements. There is no constraint on special character.

e.g.

S = “giraffe”, K = 1, “011110011111111110111111”

Output : 3

How ?

normal characters : a, g, f

one of the possible solution : gir (as this has only one normal character)| Report Duplicate | Flag | PURGE

SDE-2 - 0of 0 votes

AnswerGiven a binary String which represents the target state. Minimum number of flips needed to convert a same size Binary String (with all 0’s) to target state. A flip also causes all the right bits to be flipped.

- acharyashailendra1 September 19, 2019 in India

e.g.

Input : 00101 (Represents Target)

Output : 3

Explanation :

00000 -> 00111 -> 00100 -> 00101| Report Duplicate | Flag | PURGE

SDE-2 - 0of 0 votes

AnswersN cows are standing at the origin on x-axis, each cow has some appetite, in other word hunger index. A cow can sleep of 1 unit of time or eat for one unit of time or move left or move right. There are some vessels placed on the x-axis, they are having infinite supply of fiod. Find minimum time in which all cows appetite would be filled.

- xyz September 15, 2019 in United States

Input:

cow Apetitte = {1,1}

Vessle locations = {-1,1}

Answer would be 2 since both cow can go in different direction they would eat for one seconds. One second for moving and one second for eating.

This problem looks to be similar to rotten eggs/tomatoes.| Report Duplicate | Flag | PURGE

Allegient SDE-2 Algorithm - 0of 0 votes

AnswerDesign and implement rate limiter for limiting api calls for a service distributed multiple users.

- acharyashailendra1 August 27, 2019 in India| Report Duplicate | Flag | PURGE

SDE-2 - 0of 0 votes

AnswerDesign data structures which support millions of products coming in streaming manner, we need to find at any moment what are top n products at any day

- acharyashailendra1 August 27, 2019 in India| Report Duplicate | Flag | PURGE

SDE-2

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

Open Chat in New Window