Recent Interview Questions
- 0of 0 votes
AnswersWe are given an array of 2n integers wherein each pair in this array of integers represents the year of birth and the year of death of a dinosaurs respectively. The range of valid years we want to consider is [-100000 to 2005]. For example, if the input was:
- harshal.godbole2803 February 02, 2013 in United States
-80000 -79950 20 70 22 60 58 65 1950 2004
it would mean that the first dinosaur had a birth year of –80000 and an year of death of –79950 respectively. Similarly the second dinosaur lived from 20 to 70 and so on and so forth.
We would like to know the largest number of dinosaurs that were ever alive at one time. Write a method to compute this, given the above array of 2n integers.| Report Duplicate | Flag | PURGE
Algorithm - 0of 0 votes
AnswersYou are given an input form such as the following
- panoptic.biopower November 01, 2012 in United States
(1, (2, 3), (4, (5, 6), 7))
Each element is either a number or a list (whose elements may also be numbers or other lists).
Output the numbers as they appear, stripped down into a single list.
E.G. (1, 2, 3, 4, 5, 6, 7)
(Complication - how does your code handle the case of ((((5)))) vs just ( 5 ) ? )| Report Duplicate | Flag | PURGE
Facebook Intern Coding - 0of 0 votes
AnswersGiven an array and a key, sum min subarray whose sum is no less than key. O(n) Time needed
- Steve October 14, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 0 votes
AnswersI have an arrayList A which contains say 2,3,5,7,8
- gadha October 04, 2012 in India
I have another arrayList B which contains 1, 3
Now taking the elements of B as the locations, I need to remove the elements of A present in that locations. So, basically I need to remove the element 2(position 1) and 5(position 3) from A. How to achieve it as we know that once one element got removed from an arrayList,the positions will be auto adjusted.| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Java - 0of 0 votes
AnswersWrite a C function to remove all spaces from a string.
- CodeSpace October 03, 2012 in United States
Follow-up question: Explain the space and time efficiency of your solution.| Report Duplicate | Flag | PURGE
Apple Software Engineer / Developer String Manipulation - 0of 0 votes
AnswersWrite an algorithm to insert a new value into a circular sorted linked list.
- Andy2000 September 04, 2012 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersFind sub-array in an array of integers whose sum is maximum, integers can be negative, zero or positive.
- Naveen Reddy Mandadi August 25, 2012 in United States| Report Duplicate | Flag | PURGE
Microsoft Applications Developer Algorithm - 0of 0 votes
AnswersGiven an array of 32bit unsigned integers in which every number appears exactly twice except three of them, find those three numbers in O(n) time using O(1) extra space. The input array is read-only. What if there are k exceptions instead of 3?
- Aashish August 12, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 2 votes
AnswersGiven API:
- jiangok2006 July 26, 2012 in United States
int Read4096(char* buf);
It reads data from a file and records the position so that the next time when it is called it read the next 4k chars (or the rest of the file, whichever is smaller) from the file.
The return is the number of chars read.
Todo: Use above API to Implement API
"int Read(char* buf, int n)" which reads any number of chars from the file.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 0of 0 votes
AnswersGiven a series of numbers as the input, the last one as the result. Use the rest numbers to calculate the result,only +, -, *, / are allowed. The order of the input cannot be changed. If there is an equation, print it; or print "no equation". If more than one solution, any working equation is fine.
- sophia July 20, 2012 in United States
example:
input: 2, 3, 1, 4
output: 2+3-1 = 4.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 0 votes
AnswersSingly LL with value as character. Please find out the word formed by character LL is palindrome or not.
- Sanjay Kumar July 16, 2012 in India
Time Complexity <n^2
Space Complexity O(1)| Report Duplicate | Flag | PURGE
Amazon - 1of 1 vote
AnswersFind the number of substrings of a string that are palindromes.
- gats July 08, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 1of 1 vote
AnswersLet's say there is a file consists of billions of records data.
- aliciabondie23 July 05, 2012 in United States
The file cannot fit into memory, and you need to reverse each word in that huge file and then save the reversed words to another file.
How would you implement this?| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven an array A[n] such that A[i+1] = A[i]+1 OR A[i]-1, and a number k, can you determine in most efficient way whether k is present in A[n] or not?
- Yoda June 12, 2012 in United States for Bing| Report Duplicate | Flag | PURGE
Microsoft Computer Scientist Algorithm - 0of 0 votes
AnswersWrite a method to sort an array of strings so that all the anagrams are next to each other.
- Pawan Sharma June 05, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Sorting - 0of 0 votes
Answersprint all compositions of a number in odd parts, i.e. for n = 8:
- pavel.em April 17, 2012 in United States
7 + 1
5 + 3
5 + 1 + 1 + 1
3 + 3 + 1 + 1
3 + 1 + 1 + 1 + 1 + 1
1 + 1 + 1 + 1 + 1 + 1 + 1 + 1| Report Duplicate | Flag | PURGE
Microsoft - 1of 1 vote
AnswersDisplay an integer array of [1, 2, 3, 4, 5, 6, 7] in the following format
- Anonymous May 09, 2011
1 4 6
2 5 7
3
The method signature takes in an array of integers and the number of columns. In the above example, noOfCols = 3. The columns should contain equal number of elements as much as possible.| Report Duplicate | Flag | PURGE
Linkedin - 0of 0 votes
AnswersReverse a linked list using recursion
- Vineet February 21, 2011| Report Duplicate | Flag | PURGE
Microsoft Jane Street Software Engineer / Developer Linked Lists - 0of 0 votes
AnswersConvert a max heap to min heap.
- Shane007 October 18, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
Answersyou have given a node of a tree. that node is defined as below:
- Neetu August 12, 2010
node(
int value,
node left;
node right;
node grandparent)
at the starting the grand parent node is null in the tree. you have to assign the grandparent node for all the nodes in the tree.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Data Structures - 0of 0 votes
AnswersWrite a function to validate a SuDoKu board.
- CS June 09, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 0of 0 votes
AnswersInteger has been represented in linked list. Eg. 7541 has been represented as 7->5->4->1 with 4 nodes each having a digit. Given 2 such linked lists, you need to compute the sum of them.
- raghu.slp May 19, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
Answershow to implement a queue using one integer. this should store value 0 to 9. example suppose queue has first value 2 then insert 4 then 6 so it should look like 246. first value should be popped as 2. then it should be 46. program should support 0 in all the levels also. example queue should handle like 01235 also, 0 as first value in queue. remember 0 just to use integer, nothing else as data storage.
- Justin January 13, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersFind minimum number of characters that need to be inserted into a string (anywhere in the string) to make it a palindrome..(Hint: Interviewer expected a Dynamic Programming kind of solution)
- Anonymous November 20, 2009| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Algorithm - 0of 0 votes
Answerswhat s next in this series
- saravan06psgtech August 08, 2009
sss,scc,c,sc,?????.| Report Duplicate | Flag | PURGE
Amazon Analyst Brain Teasers - 0of 0 votes
AnswersWrite a function to add two numbers, without using any arithmetic operator. Even the ++ in for statement is not allowed
- Anonymous July 26, 2008| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer Coding Algorithm - 9of 9 votes
AnswersA circus is designing an act consisting of a tower of people standing atop one another’s shoulders. For practical and aesthetic reasons, each person must be both shorter and lighter than the person below her. Given the heights and weights of each person in the circus, what is the largest possible number of people in such a tower?
- algooz May 03, 2008
Input(ht wt) : (65, 100) (70, 150) (56, 90) (75, 190) (60, 95) (68, 110)
Output: The longest tower is length 6 and includes from top to bottom: (56,90) (60,95) (65,100) (68,110) (70,150) (75,190)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven two binary trees T1 and T2 which store character data, duplicates allowed. You have to devise an algorithm to decide whether the T2 is a subtree of T1. T1 has millions of nodes and T2 has hundreds of nodes.
- vodangkhoa December 15, 2007| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersHere's one I got asked which kicked my butt. Write a function that takes in an array of n ints from 1...n-1. For example, an array of 4 numbers which all have values of 1, 2, or 3. There will obviously be at least one duplicate number. Return one of the duplicates (EASY!) - Now do this in order n, without allocating ANY new memory (no hash table or anything)..
- Mike Christensen November 12, 2007
(Note: I did figure out a solution to this, but the interview didn't seem to like it very much but whatever)..| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm