Algorithm Interview Questions
- 1of 1 vote
AnswersQ 1. You are given an array of integers, contains positive, negative and zeros. You have to written subarray whose sum is maximum in this array.
- sonesh April 28, 2017 in United States
Desired Complexity is O(N) + O(1)| Report Duplicate | Flag | PURGE
Hitachi Data Systems Software Engineer / Developer Algorithm Arrays - 0of 0 votes
AnswersYou have given a tree, where each node can have multiple children. You have to find if the tree has a cycle or not.
ExA / \ / \ B C / | \ | \ D E F E H | B
This tree has a cycle from B -> E -> B.
- sonesh April 28, 2017 in United States
Please note that you only know the nodes that you have traveled in the tree, so at the beginning, you will only know that there is a root node and nothing else about any other node.
The followup question was to print the cycle in the tree if found.| Report Duplicate | Flag | PURGE
Electronic Arts SDE-3 Algorithm - 1of 1 vote
AnswersFind sets of values in array whose sum is equal to some number.
- blumer April 26, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook Research Scientist Algorithm - 0of 0 votes
AnswerQ 7. You are getting a stream of integers, You have to find the median of these in real time(or with minimum complexity).
- sonesh April 26, 2017 in United States| Report Duplicate | Flag | PURGE
Two Sigma Software Engineer / Developer Algorithm - 0of 0 votes
Answersfind the isomorphic pairs of string !!
- Harsh Bhardwaj April 20, 2017 in India
a string is said to be isomorphic if its each alphabets can be replaced by another alphabet
for ex "abca" and "zxyz" are isomorphic but "abca" and "pqrs" is not isomorphic
conditions :
1 - A character can be replaced by itself. for ex "abcd" and "pbfg" are isomorphic .
2- No two characters can be replaced by same character . for ex "abcd" and "bbcd" are not isomorphic .| Report Duplicate | Flag | PURGE
AppPerfect Software Engineer Algorithm - -1of 1 vote
AnswersSorry had to remove this question
- Anonymous_geek April 19, 2017 in United States| Report Duplicate | Flag | PURGE
Software Engineer Algorithm - 1of 1 vote
AnswersWe define a k-subsequence of an array as follows
- sonesh April 18, 2017 in United States
1) it is a subsequence of consecutive elements in the array
2) the sum of the subsequence's elements s, is evenly devisible by k(i.e. s % k == 0)
Given an integer and input array, find out the number of k-subsequences.
Example: k=3 and array be [1 2 3 4 1]
Output: 4 ({1 2},{1,2,3},{2,3,4},{3})| Report Duplicate | Flag | PURGE
Expedia Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou are given a rotated sorted array of size N. You have to search a given number into it.
- sonesh April 18, 2017 in United States
Example: [4,6,8,14,90,-9,-2,0,3], Search -2.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays Sorting - 0of 0 votes
AnswersYou are given an array of words. from each word, you make a chain, in that, you remove one char at a time and you remove that char only when the remaining word is present in the input array.
- sonesh April 18, 2017 in United States
For Example, if the input is {a, b, ab, ac, aba}
then the possible chains are
from 'a', there is no chain, the chain it 'a' itself (of length 1)
similarly, from 'b', the chain length is 1 one (length is defined by the number of words in the chain)
now from 'ab', there are two possibilities which are ({ab -> b when you remove a},{ab -> a when you remove b}). So the max length is 2 here
now from 'ac', we only have one possibility which is ({ac -> a when we remove c}), because, when we remove 'a', we left with 'c' which is not present in the input.
Now, you have to find the length of the biggest such chain.
Input: array of words
Output: length of the biggest such chain.| Report Duplicate | Flag | PURGE
Two Sigma Software Engineer / Developer Algorithm String Manipulation - 1of 1 vote
AnswersVMWare Standard Online Screen
- aonecoding April 18, 2017 in United States
3rd Question Given an array of strings and a long description about the formatting of IPv6 and IPv4 (it took me more than 5 minutes to read the description). Write a function to find if a string is IPv4 or IPv6 address or neither.
4th Question Given an integer array, whenever a duplicate number is found, you may increment it (++). Find the minimum sum of the numbers in the array by keep incrementing the dups until all the numbers are unique.| Report Duplicate | Flag | PURGE
VMWare Inc Software Engineer Algorithm - 2of 2 votes
AnswerVMWare Standard Online Screen
- aonecoding April 18, 2017 in United States
The Online Assessment was called something like Life Cycle Challenge-qpan.
There are 4 questions in total given 60 minutes. The problem description was unexpectedly long that it takes 5 minutes just to read a question.
1st Question Design a function to create BST. Given an integer array, insert the integers into the binary search tree and print all the steps taken.
2nd Question Given an integer, print the index of all the positions in which the binary bit is 1 in order.| Report Duplicate | Flag | PURGE
VMWare Inc Software Engineer Algorithm - 0of 0 votes
AnswersGiven a count and maxvalue, write a program to return count number of unique random integers between 0 and maxvalue.
- Ray April 17, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 7of 7 votes
AnswersFacebook Senior Engineer On-site 2017
- aonecoding April 17, 2017 in United States
1st Round
Question 1: Binary tree to doubly linked list.
Question 2: Read 4 (Given the read4 API, read an entire file)
2nd Round
Culture fit. No coding.
3rd Round
Question: System Design POI (Point of Interest. Given a point, find things within a radius).
Lunch
4th Round
Question 1: Decode way
Question 2: Random max index
5th Round
Question: System design + component-wise design on download manager| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 6of 6 votes
Answers5th Round
- aonecoding April 13, 2017 in United States
Open-ended question What happens when you type a url in the browser and hit enter?
Second question Given an array of integers, print all the numbers that meet the following requirement - when the number is greater than every number on its left and smaller than every number on the right.| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 4 votes
Answerinterviewed by senior engineer
- aonecoding April 13, 2017 in United States
Question Given two strings s1 and s2, combine the characters in the strings and maintain the sequence of characters
Follow-up If s1 has a length of m and s2 has a length of n, how many ways the strings could be merged. Figure out the formula F(m, n) = ?| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersGiven a list of files. Return all the unique lines from all files.
- Ray April 12, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersYou are given an unsorted binary array.
- sonesh April 10, 2017 in United States
Ex [0 1 1 0 0 1 0 1 1 1 1 0 0 1 0 0 1]
and a number K, which represents the number of swap operations allowed on this binary array.
you need to find out the maximum length continuous subarray that can be generated using K many swaps.
Ex if K = 3 in above case
[0 1 1 0 0 1 0 1 1 1 1 0 0 1 0 0 1] => [0 1 1 0 0 1 1 1 1 1 1 0 0 0 0 0 1] => [0 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 0] => [0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0]
so the answer is 9.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
AnswersYou are given a binary matrix whose each row is sorted. that means each row will have zeros at front and ones at the back. You need to find out the row which contains a maximum number of ones.
Ex :[0 0 0 0 0 0 0 1 1 1 1 1] [0 0 0 0 1 1 1 1 1 1 1 1] [0 0 0 0 0 0 1 1 1 1 1 1] [0 0 0 0 0 0 0 0 0 1 1 1] [0 0 0 0 0 0 0 1 1 1 1 1] [0 0 0 0 1 1 1 1 1 1 1 1]
Ans : second row and sixth with 8 ones. you will print [2,8] and [6,8];
- sonesh April 10, 2017 in United States
Update : Required complexity O(M+N) + O(1) only.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - -4of 4 votes
AnswersFind the coordinates of the rectangle which is parallel to axis and has minimum area.
- Ray April 08, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersSuppose you have a stream of (timestamp, tag) events. You need to filter this stream (online), leaving only events with tags that haven't been already encountered in the last X seconds.
- Ray April 08, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersGiven an array of integers:
- xjohnwu April 07, 2017 in UK
1. rearrange the array such that all non-zero members appear on the left of the array (order is not important)
2. return the number of non-zero members
e.g. [1,2,0,5,3,0,4,0] => [1,2,5,3,4,0,0,0] and return 5. The non-zero array members can be in any order.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 1of 1 vote
AnswersYou are given an array of integers both negative and positive.
- sonesh April 07, 2017 in United States
Print the maximum continuous sum of the array and if all the elements are negative, print the smallest of them.
Ex : [-20, -5, -2, -9] :> -2(-2)
Ex : [20, -19, 6, 9, 4] :-> 20(20)
Ex : [10, -3, 4, -2, -1, 10] -> 18 (10, -3, 4, -2, -1, 10)
Thanks velu007 for pointing out the mistake| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Algorithm - -1of 1 vote
Answer--
- edboon06 April 06, 2017 in United States| Report Duplicate | Flag | PURGE
Backend Developer Algorithm - 0of 0 votes
AnswersDelhi Route Traffic Optimizer
- raghunitb March 30, 2017 in India for Workflow
Traffic congestion is an annoying issue in Delhi, the capital of India. Every morning thousands of people drivea residential area to the International Technology Park (ITPL). There are various routes one can take to reach ITPL and each route takes its own time making some routes faster than the others. People obviously take faster routes which causes congestion on those roads too. Congestion results into increased travel time, air pollution and wastage of fuel. As a Traffic commissioner of Delhi, you are asked to optimize the traffic by putting toll to various roads so that resultant cost of every route (driving time cost and toll cost) ends up the same. This has to be done in such a way that any driver pays toll only once no matter which route he/she takes.roads have one-way traffic and there is no cycle in any of the routes. You need to create a toll plan for a given road layout.
The toll plan must adhere to following rules:
1. Toll should be levied in such a way that perceived cost (base road cost and toll cost) remains same forroads.
2. The tolls should be levied such that the total cost for each route is minimized.
3. A route cannot have more than one toll.
4. In case of multiple solutions for a route, add toll to a road that is closer to destination.
In some use cases, it might be impossible to impose tolls that satisfy the above conditions.
http://qa.geeksforgeeks.org/11340/delhi-route-traffic-optimizer| Report Duplicate | Flag | PURGE
Groupon SDE1 Algorithm - 1of 1 vote
AnswersGiven some email ids, and a similarity function which says whether two email ids are similar, determine all the sets of email ids that are similar to each other.
- Ray March 28, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 0 votes
AnswersYou have a string consisting of open and closed parentheses, but parentheses may be imbalanced.
- Ray March 26, 2017 in United States
Make the parentheses balanced and return the new string.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 1of 1 vote
AnswersGiven a list of URLs entered by a user write a program to print unique and most recently used URLs. For example if user entered the following: -
- ik.yola March 25, 2017 in United States
1. google.com
2. yahoo.com
3. wsj.com
4. google.com
The output should be :-
1. google.com
2. wsj.com
3.yahoo.com| Report Duplicate | Flag | PURGE
Bloomberg LP Software Analyst Algorithm - 0of 0 votes
AnswersGiven a movie X that the user had watched, write an algorithm to suggest more movies to the user. How to display the other movies based on same genre?
- suneel March 24, 2017 in India| Report Duplicate | Flag | PURGE
ADP SDE-2 Algorithm - 3of 3 votes
AnswersGiven a sorted array, find all the numbers that occur more than n/4 times.
- alisonlee659 March 24, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm