## Recent Interview Questions

- 11of 11 votes

AnswersGiven a string, find whether it has any permutation of another string. For example, given "abcdefg" and "ba", it shuold return true, because "abcdefg" has substring "ab", which is a permutation of "ba".

- sg March 02, 2013 in United States| Report Duplicate | Flag | PURGE

Microsoft Software Engineer in Test String Manipulation - 5of 5 votes

AnswersGiven a source string and a destination string write a program to display sequence of strings to travel from source to destination. Rules for traversing:

- Dee November 06, 2012 in United States

1. You can only change one character at a time

2. Any resulting word has to be a valid word from dictionary

Example: Given source word CAT and destination word DOG , one of the valid sequence would be

CAT -> COT -> DOT -> DOG

Another valid sequence can be

CAT -> COT - > COG -> DOG

One character can change at one time and every resulting word has be a valid word from dictionary| Report Duplicate | Flag | PURGE

Google Site Reliability Engineer - 0of 0 votes

AnswersGiven a sorted linked list, delete all duplicate numbers, leave only distinct numbers from original list. e.g., given 1->2->3->3->4->4->5, return 1->2->5. Given 1->1->1->2->3, return 2->3.

- Anonymous July 28, 2009| Report Duplicate | Flag | PURGE

Microsoft Software Engineer in Test Testing Linked Lists - 3of 3 votes

AnswersGiven a value and a binary search tree.

- vodangkhoa April 24, 2007

Print all the paths(if there exists more than one) which sum up to that value. It can be any path in the tree. It doesn't have to be from the root.| Report Duplicate | Flag | PURGE

Microsoft Yahoo Software Engineer / Developer Trees and Graphs Coding Algorithm - -1of 3 votes

Answerswrite a method that takes in 2 int arrays of any size and returns an array that calculates the sum of both.

- J@sper November 26, 2015 in United States for -

for example, [1,2,3] and [2,3,4] will return [3,5,7]

Or [1,2,3] and [2,3,5,5] will return [2,4,7,8]

however, if it's like [9,9,2] and [0,1,3] you need to carry the sum so it returns as [1,0,0,5]

** SINGLE DIGIT ONLY| Report Duplicate | Flag | PURGE

Google Intern Arrays - 8of 8 votes

AnswersGiven the array of digits (0 is also allowed), what is the minimal sum of two integers that are made of the digits contained in the array.

- azil November 28, 2013 in United States

For example, array: 1 2 7 8 9. The min sum (129 + 78) should be 207| Report Duplicate | Flag | PURGE

Google Algorithm - 1of 1 vote

AnswersYou are given a huge log file which holds the entry and exit time of each person entering and exiting the office on a given day

- evolution monkey June 03, 2012 in United States

format of file:

entry time exit time

09:12:23 11:14:35

10:34:01 13:23:40

10:34:31 11:20:10

.

.upto N entries for a given day

Design a function which returns the total number of persons in the office at any given time. e.g input to function is 11:05:20.

The interviewer said he could call the function every second with input 11:05:20, 11:05:21,11:05:22, 11:05:23..........14:30:30

I really did not understand how to optimize the function.| Report Duplicate | Flag | PURGE

Amazon Software Engineer / Developer Algorithm - 7of 7 votes

AnswersGiven a very long list of URLs, find the first URL which is unique ( occurred exactly once ).

- AK December 06, 2011 in India

I gave a O(n) extra space and O(2n) time solution, but he was expecting O(n) time, one traversal.| Report Duplicate | Flag | PURGE

Google Software Engineer / Developer Algorithm Large Scale Computing - 1of 1 vote

AnswersFind if a binary tree is bst

- anonym October 10, 2011 in -| Report Duplicate | Flag | PURGE

Amazon Flipkart Groupon Software Engineer / Developer Trees and Graphs - 0of 0 votes

AnswersHere is a tree. It's a binary tree but in no particular order. How do you write this tree to a file so that it can be reread in an reconstructed exactly as shown?

- Kartik February 24, 2006| Report Duplicate | Flag | PURGE

Amazon Software Engineer / Developer Coding Algorithm - 5of 5 votes

AnswersGiven a number "n", find the least number of perfect square numbers sum needed to get "n"

- tazo March 12, 2015 in United States

Example:

n=12, return 3 (4 + 4 + 4) = (2^2 + 2^2 + 2^2) NOT (3^2 + 1 + 1 + 1)

n = 6, return 3 (4 + 1 + 1) = (2^2 + 1^2 + 1^2)| Report Duplicate | Flag | PURGE

Google Dynamic Programming - 3of 3 votes

AnswersQuestion: Given a sequence of positive integers A and an integer T, return whether there is a continuous sequence of A that sums up to exactly T

- ep February 27, 2015

Example

[23, 5, 4, 7, 2, 11], 20. Return True because 7 + 2 + 11 = 20

[1, 3, 5, 23, 2], 8. Return True because 3 + 5 = 8

[1, 3, 5, 23, 2], 7 Return False because no sequence in this array adds up to 7| Report Duplicate | Flag | PURGE

Facebook Software Engineer Algorithm - 6of 6 votes

AnswersGiven an array of ages (integers) sorted lowest to highest, output the number of occurrences for each age.

- streamer December 31, 2014 in United States

For instance:

[8,8,8,9,9,11,15,16,16,16]

should output something like:

8: 3

9: 2

11: 1

15: 1

16: 3

This should be done in less than O(n).| Report Duplicate | Flag | PURGE

Facebook Software Engineer / Developer Algorithm - -4of 6 votes

AnswersYou have an array of integers(size N), such that each integer is present an odd number of time, except 3 of them(which are present even number of times). Find the three numbers.

- gdg June 21, 2014 in United States for Bing

Only XOR based solution was permitted.

Time Complexity: O(N)

Space Complexity: O(1)

Sample Input:

{1,6,4,1,4,5,8,8,4,6,8,8,9,7,9,5,9}

Sample Output:

1 6 8| Report Duplicate | Flag | PURGE

Google Developer Program Engineer Arrays - 25of 27 votes

AnswersGiven a large network of computers, each keeping log files of visited urls, find the top ten of the most visited urls.

- chandeepsingh85 September 26, 2013 in United States

(i.e. have many large <string (url) -> int (visits)> maps, calculate implicitly <string (url) -> int (sum of visits among all distributed maps), and get the top ten in the combined map)

The result list must be exact, and the maps are too large to transmit over the network (especially sending all of them to a central server or using MapReduce directly, is not allowed)| Report Duplicate | Flag | PURGE

Google Software Engineer / Developer System Design - 0of 2 votes

AnswersUse SIMPLE LOGIC for Converting this string str="aaabbccc" into str="3a2b3c".

- Anonymous September 23, 2013 in United States

###Note:###

I gave 3 diff solutions to interviewer with loops,conditions etc.,But he wanted a real OPTIMAL SOLUTION..lets see who ll write!!!!!| Report Duplicate | Flag | PURGE

Amazon Developer Program Engineer - 3of 5 votes

AnswersGiven two singly linked list, find if they are intersecting. Do this in single iteration. Also find the intersecting node in O(n) time and O(1) space. By intersection I mean intersection by reference not by value

- dm December 05, 2012 in India| Report Duplicate | Flag | PURGE

Amazon Microsoft Software Engineer / Developer Linked Lists - 1of 1 vote

AnswersGiven preorder traversal array of a BST, recontruct the BST.

- jiangok2006 July 26, 2012 in United States| Report Duplicate | Flag | PURGE

Google Software Engineer / Developer Coding - 0of 0 votes

AnswersThere is a building of 100 floors. If an egg drops from the Nth floor or above it will break. If it's dropped from any floor below, it will not break. You're given 2 eggs. Find N, and minimize the number of drops for the worse case.

- vodangkhoa December 13, 2006| Report Duplicate | Flag | PURGE

Microsoft Highbridge Capital Software Engineer / Developer Financial Software Developer Brain Teasers Algorithm - 1of 1 vote

AnswersYou are tasked with implementing a method that returns the lowest possible number that could be generated after removing n characters from a string of digits. The method signature should look like:

`public static string GenerateLowestNumber(string number, int n)`

Where the number parameter is a string that contains a number (e.g. “4205123”), and the n parameter represents the number of characters to remove from the string. The goal of this method is to return the lowest number that can be generated by removing n characters from the number provided while keeping the positions of the remaining characters relative to each other the same (i.e. the method should remove n characters from the string, but it cannot re-order the characters).

- JSDUDE March 14, 2015 in United States for Cloud + Enterprise

For example, if number is “4205123” and n is 4, the lowest possible number that can be generated after removing any 4 characters is “012”. If number is “216504” and n is 3, the lowest possible number that can be generated after removing 3 characters is “104”.| Report Duplicate | Flag | PURGE

Microsoft Software Developer Algorithm String Manipulation - 7of 7 votes

AnswersDetermine minimum sequence of adjacent values in the input parameter array that is greater than input parameter sum.

- bootcat April 20, 2014 in United States

Eg

Array 2,1,1,4,3,6. and Sum is 8

Answer is 2, because 3,6 is minimum sequence greater than 8.| Report Duplicate | Flag | PURGE

Google Software Engineer / Developer Algorithm - 1of 1 vote

Answers1. A

- amklo December 30, 2010

2. Ctrl+A

3. Ctrl+C

4. Ctrl+V

If you can only press the keyboard for N times (with the above four keys), please write a program to produce maximum numbers of A. If possible, please also print out the sequence of keys.

So the input parameter is N (No. of keys that you can press), the output is M (No. of As that you can produce).| Report Duplicate | Flag | PURGE

Google Software Engineer / Developer Algorithm - 1of 3 votes

AnswersGiven a random string S and another string T with unique elements, find the minimum consecutive sub-string of S such that it contains all the elements in T.

- Saghar H November 05, 2015 in United States

example:

S='adobecodebanc'

T='abc'

answer='banc'| Report Duplicate | Flag | PURGE

Facebook Software Developer Algorithm - 4of 4 votes

AnswersGiven a string S, you are allowed to convert it to a palindrome by adding 0 or more characters in front of it.

- xyz_coder November 20, 2014 in United States

Find the length of the shortest palindrome that you can create from S by applying the above transformation.| Report Duplicate | Flag | PURGE

Google Software Engineer / Developer - 4of 4 votes

AnswersGiven a large string T (up to 10M characters) and a large input stream of strings S(up to 1M strings), find for each Si in S if it is a subsequence of T.

- PrincessMaja November 17, 2013 in United States

String Si is a subsequence of T iff some letters from T can be omitted to obtain Si.

Example:

T - abbebcd

Si - bbcd

return true

T - abbeced

Si - bbbced

return false| Report Duplicate | Flag | PURGE

Software Engineer / Developer Algorithm - 0of 2 votes

AnswersThere are 2 arrays of integers.You have to add the those integers and keep it in 3rd array.there is one condition, if the sum is a 2 digit number, split that number into single digiit and other condition is if any of the array integer is left then print that number

- Ajay April 05, 2016 in India for amazon.in

I/P:

int[] a = {1,2,3,4,5,6}

int[] b = {2,3,4,5,6,7,8}

o/p:

{3,5,7,9,1,1,1,3,8}| Report Duplicate | Flag | PURGE

Amazon Quality Assurance Engineer Arrays - 3of 5 votes

AnswersYou're given an array of integers(eg [3,4,7,1,2,9,8]) Find the index of values that satisfy A+B = C + D, where A,B,C & D are integers values in the array.

- omair.ahmed08 October 09, 2014 in United States

Eg: Given [3,4,7,1,2,9,8] array

The following

3+7 = 1+ 9 satisfies A+B=C+D

so print (0,2,3,5)| Report Duplicate | Flag | PURGE

Facebook Software Engineer / Developer Algorithm Arrays Data Structures - 2of 4 votes

AnswersThere is an array of 3-tuple, in the form of (a, 1, 5). The first element in the tuple is the id, the second and third elements are both integers, and the third is always larger than or equal to the second. Assume that the array is sorted based on the second element of the tuple. Write a function that breaks each of the 3-tuple into two 2-tuples like (a, 1) and (a, 5), and sort them according to the integer.

- Nobody September 11, 2014 in United States

E.g. given (a, 1, 5), (b, 2, 4), (c, 7, 8), output (a, 1), (b, 2), (b, 4), (a, 5), (c, 7), (c, 8).| Report Duplicate | Flag | PURGE

Google Software Engineer / Developer Algorithm - 4of 4 votes

AnswersYou are given a large set of integers, which are not sorted. Figure out a method to retrieve the largest 1000 elements, in O(n) run time

- varunumesh77 March 12, 2014 in United States| Report Duplicate | Flag | PURGE

Amazon Intern Algorithm Data Structures

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window