Recent Interview Questions
- 2of 2 votes
AnswersYou have a LinkList with each node having Next node and Other node and Data.
- CodeBuster May 23, 2014 in United States
i.e. Class Node
{
Node Next;
Node Other;
int Data;
}
Next pointer always points to next node and Other node can point to any other node in the list or can be pointing to null/nothing or can point to self.
Write program to copy this link list to a new list with proper Next and Other pointers.| Report Duplicate | Flag | PURGE
Expedia Software Engineer in Test - 2of 2 votes
AnswersGiven 2 sorted array print their intersection.
- morpheus September 26, 2009| Report Duplicate | Flag | PURGE
Google Software Engineer in Test Arrays - 2of 2 votes
AnswersWhen a person who knows it meets any other person, they immediately share the story with them.
- veeru June 25, 2021 in India
Initially, only person 1 knows the story. Given a list of meetings between people in a form of
(person_1_id, person_2_id, timestamp) construct a list of the persons who will know the story
at the very end.
Example: [(1, 2, 100), (3,4, 200), (1,3, 300), (2,5, 400)], 1 // The events could be out of order.
Person 2 will learn the story at the moment 100, person 3 — at the moment 300,
person 5 — in the moment 400. Person 4 will never learn the story. So the answer is [1, 2, 3, 5].
Eg2: [(1, 2, 100), (2, 3, 100), (4, 5, 100)], 2
where the first parameter is array of the Persons meet at particular timestamp, second parameter is the PersonId who knows the story first.
Output: [1, 2, 3]| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures - 2of 2 votes
AnswersWrite a function to return string when passed integer . Note : do not use tostring() in built function.
- raghunath.e November 14, 2019 in United States
E.g 123 --> "123"| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test technical - 2of 2 votes
AnswersYou are given n points (x1, y1), (x2, y2), ..... (xm, ym) of a two dimensional graph. Find 'n' closest points to (0,0) [ n <= m ]. Euclidean distance can be used to find the distance between 2 points.
- MM2181 August 19, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Web Developer - 2of 2 votes
AnswersQuestion : Given a set of N numbers [1,N], partition them into 2 disjoint subsets based on a set of K queries.
- robb.krakow July 25, 2018 in United States
Each query is of the type (n1, n2) where n1 and n2 are distinct numbers from the set and n1 and n2
belong to opposite subsets.
Example:
Input:
Input:
N = 4
K = [(1, 2), (1, 3), (2, 4)]
Output:
Set 1 : (1,4)
Set 2 : (2,3)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Data Structures - 2of 2 votes
AnswersPrint Common Suffix In Strings
- praveenz.poola September 15, 2017 in India
Ex: cornfiled , Exfiled --- field| Report Duplicate | Flag | PURGE
Cisco Systems Software Engineer Java - 2of 2 votes
AnswersPassword Suggestor: Replace s with $ and a with @ and produce all password suggestions.
- Interviewee2017 May 03, 2017 in United States
For Example: Password : P@ssword, P@$$word,pas$word etc..| Report Duplicate | Flag | PURGE
Amazon Software Developer - 2of 2 votes
AnswersFind three non-overlap windows of size k in an int array, that together has a maximum sum
- ajay.raj March 14, 2017 in United States
of the 3k entries.
example
int[] nums = [1,2,1,2,6,7,5,1]
k = 2
output
[1,2],[2,6],[7,5]| Report Duplicate | Flag | PURGE
Google Software Engineer - 2of 2 votes
AnswersJust a disclaimer: I doubt you will ever get this interview question. My interviewer even started off by saying, "Hmm, well this isn't really fair, but..." So don't place too much stock in whether or not you can solve this.
- oxymoronic2012 November 02, 2016 in United States for Bing
Question: You have a group of pigs and buckets of food for said pigs. There are 1,000 buckets of food, and exactly 1 of them is poisoned. Your goal is to determine, by the end of 1 hour, which bucket is poisoned.
The poison takes 30 minutes to kill a pig, and you'd like to kill as few pigs as possible. The number of pigs you can test is limitless, and you can assign a number to each bucket and each pig so that you know exactly which pig ate from which bucket(s). You determine which buckets to feed to which pigs, but you have no timer and no way to guesstimate the time. What is the minimum number of pigs you need to use to solve the problem?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Intern Brain Teasers - 2of 2 votes
AnswersGiven a binary tree print it in inward spiral order i.e first print level 1, then level n, then level 2, then n-1 and so on.
- neer.1304 December 10, 2015 in United States
For Ex -
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
Print- 1 15 14 13 12 11 10 9 8 2 3 7 6 5 4
Follow up question - Extend the algorithm to n-ary tree.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 2of 2 votes
AnswersData structure which supports both map operations and array operations without time complexity penalty.
- Ray November 14, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer in Test Data Structures - 2of 2 votes
AnswersGiven an Integer where only one Bit is set, Identify that Bit in O(1).
- Enkesh Gupta July 11, 2015 in United States| Report Duplicate | Flag | PURGE
Deshaw Inc - 2of 2 votes
AnswersYou are given a bag with N balls (where the value of N is unknown). Each ball in the bag is uniquely numbered with a value between 1 to N (inclusive) i.e. for each number between 1 and N, there is only one ball with that number. Now you pick a ball from the bag and see its number. You repeat this experiment K times. What is the best possible estimate of the value of N (the number of balls in the bag) you can make from the above experiment (of taking out a ball from the bag K times) in the following cases
- dush.dhyani May 20, 2015 in India
a) With replacement
b) Without replacement.| Report Duplicate | Flag | PURGE
Microsoft Intern Math & Computation - 2of 2 votes
AnswersYou are given a function: List<TimeSlot> getTimeSlots (String friend)
- h3ssam March 15, 2015 in United States
Assume getTimeSlots() returns available times for a friend, sorted in order, with no overlap.
Assume TimeSlot has comparable function
You want to schedule a meeting among all of your friends, such that all can attend.
Implement a function to get the first 3 common TimeSlots among all your friends:
List<TimeSlot> get3CommonTimeSlots (List<String> friends)
user1 1-2pm, 3-4pm, 7-8pm
user2 1-2pm, 5-6pm| Report Duplicate | Flag | PURGE
Amazon Intern Algorithm - 2of 2 votes
AnswersWe have two strings A and B with the same super set of characters. We need to change these strings to obtain two equal strings. In each move we can perform one of the following operations:
- Dusan Punosevac September 21, 2014
1- swap two consecutive characters of a string
2- swap the first and the last characters of a string
A move can be performed on either string.
What is the minimum number of moves that we need in order to obtain two equal strings?
Input Format and Constraints:
The first and the second line of the input contains two strings A and B. It is guaranteed that the superset their characters are equal.
1 <= length(A) = length(B) <= 2000
All the input characters are between 'a' and 'z'
Output Format:
Print the minimum number of moves to the only line of the output
Sample input:
aab
baa
Sample output:
1
Explanation:
Swap the first and last character of the string aab to convert it to baa. The two strings are now equal.| Report Duplicate | Flag | PURGE
- 2of 2 votes
AnswersGiven a normal binary tree, write a function to serialize the tree into a string representation (returning the string), and also a function to deserialize a serialized string into the original binary tree.
- Microwish February 25, 2014 in China| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven a string S1, convert it to another string S2 (Anagram) by swapping only adjacent elements. Print all the intermediate strings formed.
- Nascent February 08, 2014 in India
eg: s1: abcde
s2: bcdae
output: bacde,bcade, bcdae.
like wise.| Report Duplicate | Flag | PURGE
Amazon - 2of 2 votes
AnswersSort a list of numbers in which each number is at a distance k from its actual position
- Madan January 28, 2014 in United States| Report Duplicate | Flag | PURGE
Google SDE1 - 2of 2 votes
AnswersThere is a sentence that your friend knows, but while giving it to you, he lost all the spaces. You have a dictionary with you, that will tell you given word exist or not. How would you reconstruct the original sentence using it.
- Vin October 23, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 2of 2 votes
AnswersGiven a snake and ladder game, write a function that returns the minimum number of jumps to take top or destination position.
- Vin August 17, 2013 in India
You can assume the die you throws results in always favor of you.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 2of 2 votes
Answershow much memory can calloc and malloc can allocate???
- saran August 17, 2013 in India| Report Duplicate | Flag | PURGE
Samsung C - 2of 2 votes
AnswersFind the majority element which occurs more than n/2 times in an array of n size, which contains duplicate elements in minimum time and space complexity.
- saran August 07, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Arrays - 2of 2 votes
Answers'K' number of char arrays of different length are given, find Cartesian product of them in optimal way & give complexity. I used divide & conquer.
- ameyabap February 23, 2013 in India for AppeX| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 2of 2 votes
AnswersYou have two very large numbers that cannot be stored in any available datatypes. How would you multiply them?
- confused_coder August 08, 2016 in United States
How would you multiply more than two numbers?| Report Duplicate | Flag | PURGE
Microsoft SDE-2 - 2of 2 votes
AnswersYou are designing a system the records website visits. The interface for this system is:
- taylor.halliday April 26, 2016 in United States
void recordHit();
long getCount();
`getCount()` returns the amount of hits to the site for only the last 5 minutes.
Your task is to code `recordHit()` and `getCount()`| Report Duplicate | Flag | PURGE
Dropbox Software Engineer Algorithm - 2of 2 votes
AnswersGiven a number (integer) as a string turn in into a number:
- tamashionuth January 02, 2016 in United States
E.g. "One million two hundreds thousands fifty seven" => shoud return 1200057.
How to model it and how to test it? What data structures would you use. Deep testing (corner cases)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm - 2of 2 votes
AnswersHow to find middle element in a linked list without knowing the length of the linked list
- D PRAVEEN KUMAR December 10, 2015 in India| Report Duplicate | Flag | PURGE
unknown Applications Developer Data Structures - 2of 2 votes
AnswersGiven a cube made of N x N x N sub-cubes, how many sub-cubes are on the outside of the cube?
- lindat September 29, 2015 in United States| Report Duplicate | Flag | PURGE
Zynga Software Development Manager Puzzle