Problem Solving Interview Questions
- 0of 0 votes
AnswersGiven a function “f” in which 0 occurs with probability 0.4 and 1 occurs with probability 0.6. Using function “f” deduce a new function “f1” such that both 0 and 1 occurs with probability 0.5
- sam February 14, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Problem Solving - 1of 1 vote
AnswersTo find loop in a circular linked list, we generally move two pointers , one with speed of one move at a time and other at two at moves at a time. Why do we use ratio 2:1. What can be the best ratio of speed to find a loop in linked list
- NIC January 30, 2014 in India| Report Duplicate | Flag | PURGE
Adobe Member Technical Staff Problem Solving - 2of 2 votes
AnswersThere is a large file( 1TB) containinig braces. Question is to check for their balance. I said will use a counter, will increment on an open brace and decrement on an close brace. If counter goes negative or counter is non zero at the end of the file, braces are not balanced. Otherwise balanced. Followup question was to make this process parallel ( meaning to see if this problem can be solved through parallelism, like dividing the the problem into sub problem....) Remember the file is very large.
- gns January 23, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Problem Solving - 1of 1 vote
AnswersThere is a king, who has got 1000 bottles of Rum with him, of which One bottle contains poison. And he has any number of slaves. He has got 1 hour to decide which bottle contains Poison, and any slave who even takes a sip of the poison, dies within an hour. How many least number of slaves does the king need to use, to make out which bottle contains poison.
- pal January 22, 2014 in India| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Problem Solving - 0of 0 votes
AnswersThere is a website, which is working fine in US, but not working in India. Debug the scenario.
- pal January 22, 2014 in India| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Problem Solving - 0of 0 votes
AnswersYou have a Movie file, which is not getting played in VLC player. Debug the scenario.
- pal January 22, 2014 in India| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Problem Solving - 2of 2 votes
Answers5! = 5 * 4 * 3 * 2 * 1 = 120 (it contains 1 zero).
- pal January 22, 2014 in India
How many zeroes will be contained in 100! then.
Explain with logic.| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Problem Solving - 0of 2 votes
AnswersDesign a Logging mechanism. Should be thread safe.
- R@M3$H.N January 07, 2014 in India
Initially i came up with Command Pattern, and write into a File. Was asked how i will synchronize multiple threads writing into Same File?
Later he gave hint about Aspect-oriented Programming(AOP). And also he gave a hint of Not always writing into the File, can also be a Mail,etc..| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Data Structures Problem Solving System Design Threads Unix - 0of 0 votes
AnswersYou are given a binary array with N elements: d[0], d[1], ... d[N - 1].
- kesar January 02, 2014 in United States
You can perform AT MOST one move on the array: choose any two integers [L, R], and flip all the elements between (and including) the L-th and R-th bits. L and R represent the left-most and right-most index of the bits marking the boundaries of the segment which you have decided to flip.
What is the maximum number of '1'-bits (indicated by S) which you can obtain in the final bit-string?
'Flipping' a bit means, that a 0 is transformed to a 1 and a 1 is transformed to a 0 (0->1,1->0).
Input Format
An integer N
Next line contains the N bits, separated by spaces: d[0] d[1] ... d[N - 1]
Output:
S
Constraints:
1 <= N <= 100000
d[i] can only be 0 or 1f
0 <= L <= R < n
Sample Input:
8
1 0 0 1 0 0 1 0
Sample Output:
6
Explanation:
We can get a maximum of 6 ones in the given binary array by performing either of the following operations:
Flip [1, 5] ==> 1 1 1 0 1 1 1 0| Report Duplicate | Flag | PURGE
VMWare Inc Problem Solving - 7of 7 votes
AnswersYou need to develop the game Snake. What data structures will you use? Code your solution.
- GeorgyBoy December 30, 2013 in Israel| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Coding Java Problem Solving - 2of 4 votes
AnswersGiven a sorted array of integers, write a function that will return the number with the biggest number of repetitions.
- GeorgyBoy December 30, 2013 in Israel
(Asked to refine the solution to be more efficient)| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays Coding Data Structures Problem Solving Sorting - 3of 3 votes
AnswersGiven a board made of 2 x n squares, and boards made of 2 x 1 squares, write a function that will calculate the number of possible ways to arrange the 2 x 1 boards on the 2 x n board, in a way that will fill it completely.
- GeorgyBoy December 30, 2013 in Israel
(Asked to refine the solution to be more efficient)| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Coding Problem Solving - 0of 0 votes
AnswersYou have three covered baskets labelled "Apples", "Oranges" and "Mixed." All of them are labelled incorrectly. Choosing only one fruit from one of the baskets (and not peeking inside), how can you determine how to relabel the baskets?
- peaceloveharmony@live.ca November 15, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Intern Problem Solving - 0of 2 votes
AnswersYou have a gold bar with seven segments. For seven days, you must pay an employee with one gold segment each day. Breaking the bar only twice, how can you ensure the employee gets paid appropriately?
- peaceloveharmony@live.ca November 15, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Intern Problem Solving - 0of 0 votes
AnswersWrite a 10 digit number in such a way that the 1st digit will describes the no. of occurrence of 1, 2nd digit , no. of occurrence of 2 and so on 9th digit, the no. of occurrence of 9 in the 10 digit number.
- anilsk89 November 08, 2013 in India| Report Duplicate | Flag | PURGE
MAQ Java Developer Problem Solving - -3of 5 votes
AnswersIf you have a 10G file and only 2G of memory, how can you fit the file into the memory. Describe the solution and write the code.
- curious September 03, 2013 in United States| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer Problem Solving - 1of 1 vote
AnswersA young girl counted in the following way on the fingers of her left hand. She started calling the thumb 1, the index finger 2, the middle finger 3, the ring finger 4, the little finger 5, then reversed direction calling the ring finger 6, the middle finger 7, the index finger 8, the thumb 9 then back to the index finger for 10, the middle finger for 11, and so on. She counted up to n (to be input by the user). She ended on her which finger?
- Saurabh Singhal August 17, 2013 in India| Report Duplicate | Flag | PURGE
Goldman Sachs Intern Problem Solving - 1of 1 vote
AnswersIn an N*M grid, in how many ways can you reach from top left (0,0) position to an arbitrary location (i,j) provided you can only move to the right or to the bottom in one step?
- Murali Mohan July 22, 2013 in India for Bangalore
How do you compute the number of ways from (0,0) to (i,j) if there are arbitrary number of blocks on the way?| Report Duplicate | Flag | PURGE
Amazon SDE-2 Problem Solving - 0of 0 votes
AnswersGiven n, how many structurally different binary trees can be formed?
- Murali Mohan July 16, 2013 in India for Bangalore
For ex: n = 1 => one tree
n = 2 => two trees
O O
/ \
O O
n = 3 => five trees
O O O O O
/ \ \ / / \
O O O O O O
/ \ / \
O O O O| Report Duplicate | Flag | PURGE
Amazon SDE-2 Problem Solving - 1of 1 vote
AnswersImplement T9 dictionary for mobile phone
- anim June 29, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Algorithm Application / UI Design Data Structures Object Oriented Design Problem Solving - 0of 0 votes
AnswersGiven a number of N-digits A, I want to find the next least N-digit number B having the same sum of digits as A, if such a number exists. The original number A can start with a 0. For ex: A-> 111 then B-> 120, A->09999 B-> 18999, A->999 then B-> doesn't exist.
- srk.iitg June 19, 2013 in United States| Report Duplicate | Flag | PURGE
Problem Solving - 0of 0 votes
AnswersGiven a list of test results (each with a test date, Student ID, and the student’s Score), return the Final Score for each student. A student’s Final Score is calculated as the average of his/her 5 highest test scores. You can assume each student has at least 5 test scores.
You may use the JDK or the standard template library. The solution will be evaluated on correctness, runtime complexity (big-O), and adherence to coding best practices. A complete answer will include the following:
Document your assumptions
Explain your approach and how you intend to solve the problem
Provide code comments where applicable
Explain the big-O run time complexity of your solution. Justify your answer.
Identify any additional data structures you used and justify why you used them.
Only provide your best answer to each part of the question.
Use the following skeleton for your solutions.
Java:
- aopencv June 16, 2013 in United Statesclass TestResult { int studentId; String testDate; int testScore; } public class FinalScoreQuestion { Map <Integer, Double> calculateFinalScores (List<TestResult> results) { }
| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Java Problem Solving Sorting - 0of 0 votes
AnswersMerge the given 2 input sorted arrays of numbers into one . The merged array stays sorted .
- meek May 31, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Arrays Java Problem Solving Sorting - -5of 7 votes
Answersneed to implement a weather report functionality. user will provide the city name , need to return the weather report.
- gopi.komanduri May 29, 2013 in India
if weather station exists n functioning properly , will return the weather report of that station .
else ,
will return the nearest available weather station report.
interviewer looking for optimized manner.
looking for datastructures to stores the cities n algo to return the report.| Report Duplicate | Flag | PURGE
Mentor Graphics Analyst Algorithm Arrays Bit Manipulation Brain Teasers C C# C++ Cache Coding Computer Architecture & Low Level Data Mining Data Structures Dynamic Programming General Questions and Comments Graphics Hash Table Ideas Linked Lists Math & Computation Object Oriented Design Problem Solving Sets Sorting Stacks String Manipulation Terminology & Trivia Threads Trees and Graphs XML - 0of 0 votes
Answersgiven an array of charactes have to replace space with %20. where %20 is considered as 3 characters.write complete code to implement this.
ps: assume that array has enough space at the end that can fit one space character to 3 chacters(%20).
- anushvenki May 12, 2013 in Indiaimport java.io.* char fn(char [] word) { for(int i =1;i<=word.length();i++) { if(char[i]==" " && isArrayRightShiftable(word)){ shiftArrayToRight(word,i); char[i]='%'; char[i+1]='2'; char[i+2]='0'; } } return word; } private boolean isArrayRightShiftable(char[] word) { if(word.length()+2 < 50){ return true; } return false; } private void shiftArrayToRight(char[] word, int i) { for(int j = word.length();j>=i;j--) word[j+2]=word[j]; }
| Report Duplicate | Flag | PURGE
Amazon Applications Developer Problem Solving - 0of 0 votes
AnswersGiven a non sorted array consisting 0's and 1's. find the index of first '1'. write a complete program which takes less time complexity. and test all boundary conditions also.
- PKT April 29, 2013 in United States
Eg: If given array is 0,0,0,1,0,0,0,1,1,1,1 the out put should be 3.| Report Duplicate | Flag | PURGE
Problem Solving - 2of 2 votes
AnswersWrite a function that finds out if any two numbers within that array add up to a target.
- Bheesham March 27, 2013 in United Statesbool addsUp(Array<int> input, int target);
| Report Duplicate | Flag | PURGE
Amazon Intern Algorithm Problem Solving - 1of 1 vote
AnswersGiven an unsorted set of numbers from 1 to 10 with one number missing .
- tom March 20, 2013 in United States
How to find the missing number in the set without sorting. How to find if two numbers are missing in the set?| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer Intern Problem Solving