SDE1 Interview Questions
- 0of 0 votes
AnswersGiven a group of movies and their start time, assuming that are 1 hour long,
- ajay.raj July 15, 2017 in United States
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) {
}| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
Answersfriend circle. Given a streaming pairs representing friend relationship
- ajay.raj July 15, 2017 in United States
(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){
}| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
Answersgiven a matrix and a target, return if there is a path who’s sum is == target
- ajay.raj July 14, 2017 in United States
Input: matrix, integer output: true or false;| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
Answerspermute the String including case change
- ajay.raj July 14, 2017 in United States
"abc".
For example:
abc
ABC
Abc
aBc
abC
ABc
abC
AbC| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
Answersimplemnt JSON.stringify()
- ajay.raj July 14, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
AnswersGiven transactions between group of friends. How to minimize the number of transactions by eliminating redundant cash flow paths?
- imrohitkhatri June 29, 2017 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswerDesign 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.
- disaster007 June 27, 2017 in United States for Prime
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.| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersDesign 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.
- disaster007 June 27, 2017 in United States for Prime| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswerGiven 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
- disaster007 June 27, 2017 in United States for Prime| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersBalance a string with parentheses. "a(b)" -> "a(b)"; "(((((" -> ""; "(()())" -> "(()())"; ")ab(()" -> "ab()"; etc...
- ad09 June 26, 2017 in United States| Report Duplicate | Flag | PURGE
Google SDE1 - 0of 0 votes
Answerscan you use union find to Detect Cycle in a Directed Graph? why or why not
- ajay.raj June 14, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
AnswersShell command, there is a log file, you want all the "error" inside the line to find out into another file inside,
- ajay.raj June 11, 2017 in United States
What instruction,| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
Answerhow to design github
- ajay.raj June 11, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
AnswersReturn the most popular 10 words in the past 24 hours for twitter
- ajay.raj June 09, 2017 in United States
Follow up in order to reduce the size of each log, do not write timestamp, how to get the same answer,| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
AnswersGiven a Calendar class (there are three fields, year, month, day) and a number of N,
- ajay.raj June 08, 2017 in United States
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}| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
Answersimplement a Fibonacci iterator
- ajay.raj June 08, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook SDE1 - -1of 1 vote
AnswersNow we have one server, one database, what if response time is slow?
- ajay.raj June 08, 2017 in United States
How to optimize?| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
AnswersGiven an integer n, count the total number of digit 3 appearing in all non-negative integers less than or equal to n.
- ajay.raj June 08, 2017 in United States
(E.x: given 30, return 4 {3,13, 23, 30})| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
Answersprime factors. given a number return the prime factor multiplication.
- ajay.raj June 08, 2017 in United States
eg. 90 = 2 * 3 * 3 * 5.| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
AnswersRemove any number containing 9 like 9, 19, 29, ... 91, 92, ... 99, 109...
- ajay.raj June 08, 2017 in United States
Write a function that returns the nth number. E.g. newNumber(1) = 1
newNumber(8) = 8, newNumber(9) = 10| Report Duplicate | Flag | PURGE
Facebook SDE1 - -1of 1 vote
AnswersGiven a stream of objects, O1, O2, O1, O3, O4... Provide an algorithm to identify the first unique object at any given point in time.
- abhi10901 May 31, 2017 in United States for AWS Auto Scaling
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...| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
Answers/* Find all subsets of size k in an array that sum up to target
- ajay.raj May 31, 2017 in United States
the array may contains negative number */
class Solution {
public List<List<Integer>> combinationSum(int[] nums, int target, int k) {
}| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
AnswersA 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
- ajay.raj May 31, 2017 in United Statesclass Log{ String id; int time; } public HashSet<String> getBots(Log[] logs, int m, int n){ }
| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
Answershow to implement a Wish List like this one
- ajay.raj May 30, 2017 in United States
https://www.amazon.com/hz/wishlist/intro| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
Answersdownload all urls from 1000 hosts. Imagine all the urls are graph.
- ajay.raj May 28, 2017 in United States
Requirement: Each host has bad internet connection among each other, Has to download url exacly once.| Report Duplicate | Flag | PURGE
Facebook SDE1 - 1of 1 vote
AnswersLast Monday phone interview of G.
- aonecoding May 27, 2017 in United States
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.| Report Duplicate | Flag | PURGE
Google SDE1 Algorithm - 0of 0 votes
AnswerGive 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.
- ajay.raj May 26, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook SDE1 - 1of 1 vote
AnswersThere are N gas stations along a circular route, where the amount of gas at station i is gas[i].
- majia168 May 23, 2017 in United States
You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its next station (i+1). You can begin the journey with an empty tank at one of the gas stations.
Return ALL the starting gas station's index where you can travel around the circuit once
public List<Integer> canCompleteCircuit(int[] gas, int[] cost) {
}| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
AnswersGiven n1, n2 is the number after removing one digit from n1. Example, n1 = 123, then n2 can be 12, 13 or 23.
- ajay.raj May 22, 2017 in United States
If we know the sum of n1 + n2, and find the possible values of n1 and n2.
public List<List<Integer>> getNumber(int sum){
}| Report Duplicate | Flag | PURGE
Facebook SDE1 - -1of 1 vote
AnswersDesign copy-on-write string class
- ajay.raj May 22, 2017 in United States
e.g. stringclass s("abc");
stringclass s1 = s; // no copy
s = "bcd"; // copy| Report Duplicate | Flag | PURGE
Facebook SDE1