## SDE1 Interview Questions

- 1of 1 vote
Given a review paragraph and keywords, find minimum length snippet from paragraph which contains all keywords in any order.

- 0of 0 votes
Design notification system (notify the customer with a message)

Client (delivery boy, company updates etc)

Services (Email, SMS, Watsapp)

Scaling up, fault tolerance & failure management

Flexible modifiability of clients & services

- 1of 1 vote
Dictionary of words is given

i.e. [“cat”, “dog”, “rat”, “catratdog”, “catter”]

Compound word: A word, which can be split into more than 1 valid words

get compound word, with longest string length.

- 0of 0 votes
N people are there.

knows(A,B) return true if A knows B, else false.

Celebrity: A is called a celebrity

If A knows none

Everyone knows A

Get celebrity, with less number of knows() method usage.

- 0of 0 votes
You are given a catalog of books, which have following attributes.

Name

Author

Publisher

Publish year

Category

Price

Count (sold)

Implement following APIs on top of this catalog

addBookToCatalog(Book)

searchBook(by partial book name/author)

getMostSoldBooks(by author name/category, limit)

Expectations:

Maintain DB on memory

Code should be readable. Design, handle naming convention,handle exceptions & should be running

- 0of 0 votes
Find last cell visited in 2D matrix traveresed in Spiral Fashion

- 0of 0 votes
Design an online poker game.

- 0of 0 votes
Given a server with a stack with some initial state say 1 Users can modify the stack using regular ops eg push 2 , pop etc and each op causes a version change. i.e version 1 : 1 , version 2 : 2,1 , version 3 : 3,2,1 , version 4 : 2,

You have to design it s.t person can ask for any version of the stack.

Hint : keep copies every k times and keep the ops in an nonvolatile memory

- 0of 0 votes
Given any language , you use libraries , which might use more lib etc . Find the order of building the libraries

- 0of 0 votes
Given two unsorted arrays A and B in which B can accommodate in A

How will you merge the two arrays.

- 0of 0 votes
Design a book catalog search (api’s were given for the search,full needs to be implemented as running application)

- 0of 0 votes
A solution was required to make a fantasy league with some budget allocated. Players will have some score/rating and the cost of player. Maximum score was to be achieved with eleven players.

- 0of 0 votes
A library for game 2048 was to be designed. The game can have constraints/variations which shall be defined by the game designer. The variations can be adding same numbers or adding Fibonacci numbers etc. APIs were to be exposed to the game designer.

- 0of 0 votes
Write down code in any language for a simple employee hierarchy which has 3 types of employees.

1. CEO

2. Manager

3. employee

Where an employee can have only 1 mgr, and a mgr has 1+ employees.

We were asked to input employee details(name ,id, salary,rating etc) in any order (employees might be input before his manager), create the hierarchy and implement these functionality:

1. Print hierarchy given any employee/mgr/ceo (used an n-ary tree + hash table)

2. Given a bonus and performance rating of each employee divide it to the lowest level employees(in the hierarchy ) in the ratio of their rating. i.e 100 divided among 2:3 is 40 and 60. and print the bonus of each ( simple recursive solution)

3. Top 10 employees with ratio of bonus:salary (used maxheap)

- 0of 0 votes
Given a login page come up with all possible test case from login API point of view and UI point of view.

- 0of 0 votes
What is a columnar database. why we preferred redshift over mysql for data warehouse.

- 0of 0 votes
How many ways a 4*n wall be filled with 4*1 sheets so that the wall ends uniformly.

- 0of 0 votes
Maintain an employee hierarchy with attributes

Print complete hierarchy of given employee.

find top 10 employees on the basis of salary ,at any instant of time .

Perform CRUD opérations on the hierarchy.

- 0of 0 votes
Design a state machine – Each state can handle n events and based on the event type next state is determined

- 0of 0 votes
Design delivery system from city Hub to the customer – There was focus on how to figure out the location of the customer from address, finding the shortest path etc.,

- 0of 0 votes
You are given with PxQ matrix and a point inside the matrix (x,y) where you standing. If you step outside the matrix you’ll die. You are allowed to move in all four direction. Movement will be totally random. For Given N steps, what is the probability that you’ll alive?

- 0of 0 votes
You are given some equations which may contain > or = on different-different operand. For example there are valid input and invalid (a=5, b<a=50)

String e1 = "a>b=1";

String e2 = "a>b=2";

String e3 = "a>c>e=3";

String e4 = "a>c>f=4";

String e5 = "b>a=5";

String e6 = "a>b>c=5";

String e7 = "b=7";

String e8 = "a>b>c>d=99";

String e9 = "a>b=99";

You need to create JSON string from it.

{

‘a’: {

‘b’: [1,2,99],

‘c’: {

‘e’:3,

‘f’:4

}

},

‘b’: {

‘a’ : 5

}

}

Highlighted one are invalid bec as they come they ask for overwrite the data (a>b>c = 5; C has e and f so we can overwrite.

Input: You are given those string in string array

Output:

Construct JSON

Print it

If you print in same as above (nice manner) +point

- 0of 0 votes
Code library management system

a) add a book

b) issue a book

c) return a book

d) if a user has kept a book more than 10 days then there should be a fine of Rs. 1 per day post 10 days.

- 0of 0 votes
Given daily stock rates of last year give the average stock rate price for a given day range

- 0of 0 votes
How would you design Hospital management system ?

- 0of 0 votes
There are M chocolate packets each packet can have variable number of chocolates in each packet. There are N students (N < M). Distribute chocolate packets to student such that

a) each student gets 1 packet

b) suppose m1,m2,…mn are the packets which are chosen to be distributed in sorted order of number of chocolates in them (nm-n1 must be minimum)

M = 1, 3, 4, 6 (4 packets with specified number of chocolates in them)

N = 2

Ans = 3,4

- 0of 0 votes
Assume you have a starting 4 digit number, say 1234 and and ending 4 digit number 4567. For changing a bit of a number from 1 to 3 (for example), it will take 2 steps (from 1->2 and from 2->3). So to convert 1234 to 4567, you’ll have to change each and every bit individually in some number of steps. (Change 1->4 in 3 steps, 2->5 in 3 steps and so on). Now there is a list of blacklisted numbers. So while transforming start to end, if you reach a blacklisted number, then you cannot change that particular bit, you’ll have to move to another bit. E.g. Assume 1434 is a blacklisted number, and while transforming you reach it, then you have to change either 1, or 3 or the last 4. So you have to find the least number of steps in which start number can be transformed to end number.

- 0of 0 votes
I was asked to design a snake and ladder game. The game can have more obstacles than just snake and ladders.

- 0of 0 votes
There is a n player game of cards. The deck of card is not fair, i.e. any card can be there any number of times. A card has a number and a color. Each player gets k card each (n and k can be harcoded in the solution). The computer starts the game by throwing a card from the deck of cards. Assume the card is 4 of Green. Then the other player has to throw either a 4 of any color or Green of any number. If the player does not have any such card, then it can say pass. The player who finishes all his card wins. The logic of selecting the card by the user can be hardcoded (Eg, If you use a list data structure for storing the cards for a player, then you can say that the player always throws the first card from the list). The logic was required only to start and conclude the game.

- 0of 0 votes
Two players, two field; and have multiple ships located in their fields. They are guessing each others ship position and hitting. Tell who wins first. Design maintainable code which can incorporate future change.