## SDE1 Interview Questions

- 0of 0 votes
Write the code to find the median of an unsorted array in average linear time.

followup the array is distributed across many machines.

- 0of 0 votes
Write a function to split a SQL query into individual statements.

give you a String which contains a separate Query with a semicolon ";" return all valid queries

Such as

"select name from courseinfo ;; select * from db1 where home = 'usa' ;"

The main thing to consider is that some special cases such as the escape symbol and the quotation marks inside the semicolon

public List<String> getQuery(String queries){

}

- 1of 1 vote
There is a conference room. N people are joining the conference. You have the start time and end time of each of them visiting it. You are asked to determine the maximum number of people that can be inside the room.

Example – Four people are visiting the conference

Person A B C D

Start (hour) 1 3 2 5

End (hour) 4 5 7 10

Answer will be – 3

- 0of 0 votes
Given a group of movies and their start time, assuming that are 1 hour long,

Returns a movie schedule (no time conflict).

enter:

Movie ("Shining", [14, 15, 16])

Movie ("kill bill", [14, 15])

Movie ("Pulp fiction", [14, 15])

One possible result is shining 16, kill bill 15, pulp fiction 14

public void schedule (HashMap <String, List <Integer >> map) {

}

- 0of 0 votes
friend circle. Given a streaming pairs representing friend relationship

(1, 2) means 1 and 2 are friends, (1, 3) means 1 and 3 are friends

Return all its friends.

List<Integer> getFriends (Iterator<List<Integer>> relations, int id){

}

- 0of 0 votes
given a matrix and a target, return if there is a path who’s sum is == target

Input: matrix, integer output: true or false;

- 0of 0 votes
permute the String including case change

"abc".

For example:

abc

ABC

Abc

aBc

abC

ABc

abC

AbC

- 0of 0 votes
implemnt JSON.stringify()

- 0of 0 votes
Given transactions between group of friends. How to minimize the number of transactions by eliminating redundant cash flow paths?

- 0of 0 votes
Design a suggestions list [system design] for words starting with prefix that user has typed on kindle device . The search is based on most frequent item occurring at the top to least frequent item at the bottom. Most frequent item depends on the usage of word globally.

For e.g user types "dra" . There should be a list of suggestions starting with dra such as dragon, drape, dracula etc based on their frequency of usage.

- 0of 0 votes
Design a image slide show 1) put image method 2) get image 3) random method. Random method should return a list of images such that images should be in randomized order and no image should be displayed twice without exhausting all images at once. I used list to store images . I used random class to generate randomly generated images based on the interval {0,list.size()}. But he insist on using randomization without depending on the list size.

- 0of 0 votes
Given a set of points in a plane, determine the position/angle where a yacht of 30 degree angle could be placed such that it could cover maximum points

- 0of 0 votes
Balance a string with parentheses. "a(b)" -> "a(b)"; "(((((" -> ""; "(()())" -> "(()())"; ")ab(()" -> "ab()"; etc...

- 0of 0 votes
can you use union find to Detect Cycle in a Directed Graph? why or why not

- 0of 0 votes
Shell command, there is a log file, you want all the "error" inside the line to find out into another file inside,

What instruction,

- 0of 0 votes
how to design github

- 0of 0 votes
Return the most popular 10 words in the past 24 hours for twitter

Follow up in order to reduce the size of each log, do not write timestamp, how to get the same answer,

- 0of 0 votes
Given a Calendar class (there are three fields, year, month, day) and a number of N,

Implement a function that returns the calendar after N days,

For example, if the input is {2017, 3,20} and 12, then the return is {2017,4, 1}

- 0of 0 votes
implement a Fibonacci iterator

- -1of 1 vote
Now we have one server, one database, what if response time is slow?

How to optimize?

- 0of 0 votes
Given an integer n, count the total number of digit 3 appearing in all non-negative integers less than or equal to n.

(E.x: given 30, return 4 {3,13, 23, 30})

- 0of 0 votes
prime factors. given a number return the prime factor multiplication.

eg. 90 = 2 * 3 * 3 * 5.

- 0of 0 votes
Remove any number containing 9 like 9, 19, 29, ... 91, 92, ... 99, 109...

Write a function that returns the nth number. E.g. newNumber(1) = 1

newNumber(8) = 8, newNumber(9) = 10

- -1of 1 vote
Given a stream of objects, O1, O2, O1, O3, O4... Provide an algorithm to identify the first unique object at any given point in time.

So for example, in the above, after receiving the first Object, it is unique. After receiving the second, the first is still the first unique object. After receiving the 3rd, the 1st object is no longer unique (you've not seen O1 twice), so O2 is not the first unique object. etc...

- 0of 0 votes
/* Find all subsets of size k in an array that sum up to target

the array may contains negative number */

class Solution {

public List<List<Integer>> combinationSum(int[] nums, int target, int k) {

}

- 0of 0 votes
A bot is an id that visit the site m times in the last n seconds,

given a list of logs with id and time sorted by time, return all the bots's id`class Log{ String id; int time; } public HashSet<String> getBots(Log[] logs, int m, int n){ }`

- 0of 0 votes
how to implement a Wish List like this one

https://www.amazon.com/hz/wishlist/intro

- 0of 0 votes
download all urls from 1000 hosts. Imagine all the urls are graph.

Requirement: Each host has bad internet connection among each other, Has to download url exacly once.

- 1of 1 vote
Last Monday phone interview of G.

Given a vector/list of doubly linked list pointers (a pointer is the directed linkage of two nodes), count how many independent blocks of linked lists there are for the pointers given.

- 0of 0 votes
Give you a robot and a room where you do not know where the robot is in the room and you do not know the size of the room, you have a remote control that allows the robot to walk around four directions. Here you give a move method: boolean move (int direction), direction: 0,1,2,3 that four directions. If it can move in that direction, return true, and if it cannot move in that direction, return false. Ask you determine how big this room is. the shape of the room can be any shape, so you cannot assume it is rectangle or square.