Recent Interview Questions
- 2of 2 votes
AnswersHow many string exists of the following form
- Anonymous August 08, 2010
1) Only characters from 'a' to 'z' allowed
2) No character is repeated
3) Length = 10
4) One and only one character in the string is lexicographically greater than the previous character
For example:
zyxwvutsrq = invalid (0)
zyxwvutrqs = valid! since q>r| Report Duplicate | Flag | PURGE
Apple Software Engineer / Developer - 2of 2 votes
Answers[Google On-site 2018 Winter]
- aonecoding4 November 28, 2018 in United States
Set Matrix Zeroes II
There are orbs on an NxM board ('O' denotes orb. 'X' denotes empty slot).
Whenever two orbs are in the same column or the same row, you get to erase one of them.
Try to erase as many orbs as possible.
Find the minimum number of orbs remained on board eventually.
e.g.
OXOXXO
XXXXXO
XXXXOX
erase (0,0) and get
XXOXXO
XXXXXO
XXXXOX
erase (2,0) and get
XXXXXO
XXXXXO
XXXXOX
erase (5,0) and get
XXXXXX
XXXXXO
XXXXOX
no more moves available. Return 2 e.g.
OXOXXO
XXXXXO
XXOXOX
erase(4,2), (2,2), (0,0), (2,0), (5,0)
Return 1
e.g.
OXOXXX
XOXXXO
XXXOOX
erase(0,0), (1,1), (3,2)
Return 3
Follow-up Build a solver for this board game that erases the as many orbs as possible.| Report Duplicate | Flag | PURGE
Google Software Engineer - 2of 2 votes
AnswersProblem statement
- PraTrick April 10, 2017 in India
Given a set of hotels and its guests reviews, sort the hotels based on a list of words specified by a user. The criteria to sort the hotels should be how many times the words specified by the user is mentioned in the hotel reviews.
Input
The first line contains a space-separated set of words which we want to find mentions in the hotel reviews.
The second line contains one integer M, which is the number of reviews.
This is followed by M+M lines, which alternates an hotel ID and a review belonging to that hotel.
Output
A list of hotel IDs sorted, in descending order, by how many mentions they have of the words specified in the input. If the count is same, sort according to the hotel IDs.| Report Duplicate | Flag | PURGE
Booking.com Software Engineer / Developer - 2of 2 votes
AnswersGiven a list of words with lower and upper cases. Implement a function to find all Words that have the same unique character set .
- marium27 March 14, 2017 in United States
For example:
May student students dog studentssess
god Cat act tab bat flow wolf lambs Amy Yam balms looped poodle john alice
output:
may amy
student students studentssess
dog god
cat act
tab bat
flow wolf
lambs balms
looped, poodle| Report Duplicate | Flag | PURGE
Google - 2of 2 votes
AnswersGiven points on a plane like (0,0), (1,0), (0,1), (1,1), (0,2), (2,2), (1,2). How many rectangles can be formed ?
- solveIt December 26, 2016 in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Algorithm - 2of 2 votes
AnswersYou have rating (0-10) of the hotels per user in this format:
- theconqueror July 07, 2016 in United States
scores = [
{'hotel_id': 1001, 'user_id': 501, 'score': 7},
{'hotel_id': 1001, 'user_id': 502, 'score': 7},
{'hotel_id': 1001, 'user_id': 503, 'score': 7},
{'hotel_id': 2001, 'user_id': 504, 'score': 10},
{'hotel_id': 3001, 'user_id': 505, 'score': 5},
{'hotel_id': 2001, 'user_id': 506, 'score': 5}
]
Any given hotel might have more than one score.
Implement a function, get_hotels(scores, min_avg_score) that returns a list of hotel ids that have average score equal to or higher than min_avg_score.
get_hotels(scores, 5) -> [1001, 2001, 3001]
get_hotels(scores, 7) -> [1001, 2001]
*/
How to solve this in C++ and Python?| Report Duplicate | Flag | PURGE
Google Software Engineer - 2of 2 votes
AnswersGiven an array of task and k wait time for which a repeated task needs to wait k time to execute again. return overall unit time it will take to complete all the task.
- hm September 14, 2015 in United States
Example:
1. A B C D and k = 3
ans: 4 (execute order A B C D)
2. A B A D and k = 3
ans: 6 (execute order A B . . A D)
3. A A A A and k =3
ans: 13 (A . . . A . . . A . . . A)
4. A B C A C B D A and k = 4
ans: 11 (A B C . . A .C B D A )| Report Duplicate | Flag | PURGE
Twitter Software Engineer Algorithm - 2of 2 votes
Answers
- chaos August 13, 2015 in United States for WindowsJohn observers the following while driving to work. • 4 were driving a red car. • 3 were driving a blue car. • 3 were driving a black car. He also notices that • 3 of them were listining to Hip Hop • 4 of them were listining to pop music. • 3 of them were listining to Rock. Additionally he notices that, • 3 of them reached office before time on Friday. • 3 of them reached office before time on Tuesday. • 2 of them reached office before time on Wednesday. • 2 of them reached office before time on Thursday. Which of the following practice maximises his chance of getting to office before time. a) He should drive a red car to work listining to pop music on a friday? b) He should drive a blue car to work listining to rock music on a Tuesday. State how did you calculate the probabiltiy for both in your answer.
| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Brain Teasers - 2of 2 votes
Answersgiven an expression like 3*4 + 8-9 (only +, - , * operators) as a string evaluate it strictly from left to right
- boomla March 17, 2015 in United States| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Algorithm - 2of 2 votes
Answerswrite code to validate if the input string has redundant braces?
- nnb November 03, 2014 in India
((a+b)) - Has redundant braces.
(a+(b+c)) - This doesn't has redundant braces.| Report Duplicate | Flag | PURGE
Algorithm - 2of 2 votes
AnswersTraverse a given 2D matrix from given source to destination in such way that every cell should be visited exactly one time (we have to cover all cells of matrix exactly once and have to reach at destination).
- Rahul Sharma July 12, 2014 in India| Report Duplicate | Flag | PURGE
Oracle SDE-2 Algorithm - 2of 2 votes
AnswersYou are given information about hotels in a country/city. X and Y coordinates of each hotel are known. You need to suggest the list of nearest hotels to a user who is querying from a particular point (X and Y coordinates of the user are given). Distance is calculated as the straight line distance between the user and the hotel coordinates.
- abc June 19, 2014 in India| Report Duplicate | Flag | PURGE
Google Applications Developer Algorithm - 2of 2 votes
AnswersGiven 3 Arrays of integer sorted in ascending order, get the sum of minimum difference using one element from each array.
- anonymous August 11, 2013 in India
where a, b, c are the elements from each array.
diff = |a-b| + |b-c|+|c-a|
complexitiy: worst case O(n)| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 2of 2 votes
AnswersI have a list of several million words unsorted.
- Anon August 08, 2013 in United States
How can you find the largest and the smallest words that can be typed by a single hand on a qwerty-style keyboard? Following the rules of finger placement, a word can either be typed fully on the left-hand side of the keyboard, the right-hand side, or both. Find the largest and smallest left-hand word(s), and the largest and smallest right-hand word(s).
given: millions of words, unsorted
given: set of left-hand chars - a,s,d,f,...
given: set of right-hand chars - j,k,l...| Report Duplicate | Flag | PURGE
Google Software Engineer in Test Data Structures - 2of 2 votes
AnswersHow can we implement spell checker.
- rapirapp July 04, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Data Structures - 2of 2 votes
AnswersGiven a family tree for a few generations for the entire population and two people write a routine that will find out if they are blood related. Siblings are blood related since they have the same parents. Cousins are blood related since one of their parents have the same parents etc. Design the data structure first and then write the routine.
- hsantosh71 June 15, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Trees and Graphs - 2of 2 votes
AnswersFind the Max sum subsequence in array
- JSDUDE May 04, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE1 Arrays - 2of 2 votes
AnswersWhy Amazon?
- scorpionking September 18, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Behavioral - 2of 2 votes
AnswersFive people are to be seated randomly around a circular table. What is the probability of two of them sitting next to each other?
- michael.sapozhnikov March 02, 2012 in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Java Developer Probability - 2of 2 votes
AnswersGiven a set of intervals, find the interval which has the maximum number of intersections.
- hello world February 27, 2012 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer in Test Algorithm Data Structures - 2of 2 votes
AnswersGive the inorder,postorder& preorder forms of a tree in a single traversal
- Raady October 14, 2008| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 2of 2 votes
AnswersVerify if the given strings is an anagram.
- hadeebataj May 10, 2019 in India
Ex: Str1: LISTEN, Srt2: SILENT.
Alter the program if there is more than one letter that repeats in any one of the strings.| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer String Manipulation - 2of 2 votes
AnswersWrite a code to return a value 'True' if the number '1' throughout the array appears consecutively. Ex: S = {1,1,1,0,0,3,4}.
- hadeebataj May 10, 2019 in India
Else, return 'False' if the array does not have the given number (char = '1' in this case) in the consecutive order. Ex: S = {1,1,0,0,1,3,4}| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Arrays - 2of 2 votes
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 - 2of 2 votes
AnswersGiven a sorted array with "n" elements, distributed them into "k" nearly equally weighing buckets.
- reddy88 April 02, 2017 in United States
Space is not constraint.
Ex: [1,3,6,9,10]
bucket size: 3
output:[10],[9,1],[3,6]| Report Duplicate | Flag | PURGE
Amazon SDE-2 Dynamic Programming - 2of 2 votes
AnswersGiven a matrix of positive integers, you have to reach from the top left corner to the bottom right in minimum cost. You can only go one square right, down or diagonally right-down. Cost is the sum of squares you've covered. Return the minimum cost.
- mrityunjay21 July 26, 2016 in India for Payments
e.g.
4 5 6
1 2 3
0 1 2
Answer: 8 (4+1+0+1+2)| Report Duplicate | Flag | PURGE
Amazon SDE-2 Dynamic Programming - 2of 2 votes
AnswersGiven a binary tree, implement an iterator that will iterate through its elements.
- carlosgsouza July 07, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersWrite a function that accepts two character arrays each represents a floating point number and return their sum in character array.
- jaip42 May 10, 2015 in India for Kindle
For example function accepts "23.45" and "2.5" and return their sum "25.95".
Restriction: We cannot use predefined functions / methods or parsing. We have to go with basic operations.| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 2of 2 votes
AnswersGiven a M * N matrix, if the element in thematrix is larger than other 8 elements who stay around it, then named thatelement be mountain point. Print all the mountain points.
- yylmaster November 13, 2014 in United States| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Algorithm