## Software Engineer Interview Questions

- -1of 1 vote

AnswersDesign Gmail backend (data storage and API)

- tested.candidate July 13, 2015 in United States| Report Duplicate | Flag | PURGE

Google Software Engineer System Design - 0of 0 votes

AnswersGiven a single core processor and 2 processes executing programs with M and N atomic instructions. How many ways can a scheduler choose to execute them?

- Gear July 11, 2015 in United States

Example:

M =2 N = 1

Output:

3

{Ma Mb Na}

{Ma Na Mb}

{Na Ma Mb}| Report Duplicate | Flag | PURGE

Software Engineer Algorithm - 7of 11 votes

AnswersThe "surpasser" of an element in an array is defined as the number of elements that are to the "right" and bigger than itself.

- carchen2015 July 10, 2015 in United States

Example:

Array:

[2, 7, 5, 5, 2, 7, 0, 8, 1]

The "surpassers" are

[5, 1, 2, 2, 2, 1, 2, 0, 0]

Question: Find the maximum surpasser of the array.

In this example, maximum surpasser = 5| Report Duplicate | Flag | PURGE

Google Software Engineer Algorithm - 2of 2 votes

AnswersGiven a binary tree, implement an iterator that will iterate through its elements.

- carlosgsouza July 07, 2015 in United States| Report Duplicate | Flag | PURGE

Google Software Engineer Algorithm - 0of 0 votes

AnswersYou have a function f1() that generates 0 or 1 with the equal probability. Write a function f29() that generates a number between 0 and 29 with equal probability.

- azaad2004 June 29, 2015 in United States| Report Duplicate | Flag | PURGE

Bloomberg LP Software Engineer Algorithm - 0of 0 votes

AnswersWrite a function to print Tree which can have any number of nodes, in level order each level in new line.

- snehit.gajjar June 25, 2015 in United States

1

2 3

4 5 6

if above is tree then answer should be,

1

2,3

4,5,6| Report Duplicate | Flag | PURGE

Groupon Software Engineer Algorithm - 3of 3 votes

AnswersPrint the level of friendship.

- AnonD June 24, 2015 in United States

Given a person and list of his friends, print all his friends by level of association.

The text file will be like one below

A: B,C,D

D: B,E,F

E: C,F,G

If the input is A, the out put should be:

Level 1 - B,C,D

Level 2 - E,F

Level 3 - G| Report Duplicate | Flag | PURGE

Amazon Software Engineer Algorithm - 4of 4 votes

AnswersYou are given 2 documents. We want to know how similar they are through N-Grams.

- um01 June 20, 2015 in United States

Given an input n (n = number of word in the Ngram) and two documents(strings) find the intersection of the NGrams of two document.

E.g doc1 = 'This is a dog'

doc2 = 'This is a cat'

n = 3

Ngrams for doc1 = 'This is a', 'is a dog'

Ngrams for doc2 = 'This is a', 'is a cat'

Output 'This is a'

Find a efficient way and give its complexity.| Report Duplicate | Flag | PURGE

Google Software Engineer - 2of 2 votes

Answersstd C library has pow(x, n) function - implement that function

- kumarr.arvind June 20, 2015 in United States| Report Duplicate | Flag | PURGE

Google Software Engineer Algorithm - 0of 0 votes

AnswersGiven a collection of pair representing intervals write a function which inserts new interval into collection and merges overlapping intervals.

- Eugene June 17, 2015 in United States

Example:

[-10, -1], [0,2], [4,10]

insert [-5, 1]

output: [-10, 2], [4, 10]| Report Duplicate | Flag | PURGE

Linkedin Software Engineer Algorithm - 10of 12 votes

AnswersGiven a max-heap represented as an array, return the kth largest element without modifying the heap. I was asked to do it in linear time, but was told it can be done in log time.

- lilzh4ng June 10, 2015 in United States| Report Duplicate | Flag | PURGE

Google Software Engineer Algorithm - 0of 2 votes

AnswersGiven a sorted array, find a way to find the # of occurrence of a number

- aj June 09, 2015 in United States

for eg: [1, 1, 2, 3, 3, 3, 4, 5]

find # of occurrence of 3 in time better than O(n)| Report Duplicate | Flag | PURGE

Google Software Engineer Algorithm - 0of 4 votes

AnswersGiven a range of floats, find the range of size 1 with max num of elements

- aj June 09, 2015 in United States

for eg: [-13.7, -14.5, -12.3, -12.5, -12.9]

one possible answer: [-12.3, -13.3]| Report Duplicate | Flag | PURGE

Google Software Engineer Algorithm - -1of 1 vote

Answers

- JSDUDE June 04, 2015 in United States`public class StringUtilities { /** * Count the maximum depth of parenthesis nesting, i.e. "abc(123(xyz))m(((n)))o" -> 3. * * @param input * any string * @return deepest parenthesization level * @throws IllegalArgumentException * if input is null or contains a mismatch "a)b(c" or "a(b" */ public static int nestedParenthesisDepth(String input) throws IllegalArgumentException { //... } }`

| Report Duplicate | Flag | PURGE

Walmart Labs Software Engineer Algorithm String Manipulation - 2of 2 votes

AnswersGiven an array and is rotated n number of times find the number where the peak happens. The array is sorted in increasing order. Follow up question: how will you rearrange them in normal sorted order.

- madhur.eng June 03, 2015 in United States| Report Duplicate | Flag | PURGE

Google Software Engineer - 0of 0 votes

AnswersSuppose you are given a puzzle that is represented as a matrix with 0s and 1s, where a 0 indicates you’re allowed to move into that position and 1 means you’re not allowed to move in that position. Write a function that given a start position and an end position, returns a boolean value indicating if there exists a path from start to end. you are only allowed to move up, left, right and down. Diagonal movement is not allowed.

- anom May 28, 2015 in United States

Example #1

Input

0 0 1 0 1

0 0 0 0 0

0 1 1 1 1

0 1 1 0 0

start: 4,1

end 0,3

Output - true

Example #2

Input

0 0 1 1 1

0 1 0 0 0

1 1 1 1 1

0 0 0 0 1

start: 0,0

end: 1,2

Output - false| Report Duplicate | Flag | PURGE

Amazon Software Engineer - 4of 4 votes

AnswersGiven an array of integer nos. All numbers are distinct.

- pavel.em May 22, 2015 in United States

WAP to find the two longest non-intersecting continuous subarrays

of equal size s.t. *all* elements of one of them are smaller than that of the other subarray:

a[i..i + k - 1] and a[j..j+k-1] where i + k <= j

s.t. a[i..i + k - 1] < a[j..j+k-1] or a[i..i + k - 1] > a[j..j+k-1]

and k is maximal

Example: a = {1,2,3, 7, 9, 8} then we have: {1, 2, 3} and {7, 9, 8}

a = {6, 5, 4, 1, 3, 7} then we have:

{6, 5} and {4, 1} or

{6, 5} and {1, 3} or

{5, 4} and {1, 3} ...| Report Duplicate | Flag | PURGE

Microsoft Software Engineer Algorithm - 0of 4 votes

Answersi18n (where 18 stands for the number of letters between the first i and the last n in the word “internationalization,”) Wiki it.

- Gcrack May 22, 2015 in United States

Generate all such possible i18n strings for any given string. for eg. "careercup"=>"c7p","ca6p","c6up","car5p","ca5up","care4p","car4up","caree3p","care3up"..till the count is 0 which means its the complete string again.| Report Duplicate | Flag | PURGE

Google Software Engineer Algorithm Arrays - 2of 2 votes

AnswersGiven an bunch of airline tickets with [from, to], for example [MUC, LHR], [CDG, MUC], [SFO, SJC], [LHR, SFO], please reconstruct the itinerary in order,

- blah_blah May 18, 2015 in United States

for example: [ CDG, MUC, LHR, SFO, SJC ].

//tickets can be represented as nodes| Report Duplicate | Flag | PURGE

Google Software Engineer Algorithm - 9of 9 votes

AnswersIf a canoe can hold 2 kids and a max weight of 150 lbs, write a function that returns the minimum number of canoes needed, given a list of kids and their weights.

- Rando May 17, 2015 in United States| Report Duplicate | Flag | PURGE

Google Software Engineer - 3of 3 votes

AnswersGiven a list of queries and their counts, write a function that returns one of the queries at random such that over time it returns an equal distribution based on the counts provided in the input.

- Rando May 17, 2015 in United States| Report Duplicate | Flag | PURGE

Google Software Engineer Algorithm - 0of 0 votes

AnswersThere are three threads in a process.

- jim.shan.JS May 15, 2015 in United States

The first thread prints 1 1 1 …, the second one prints 2 2 2 …, and the third one prints 3 3 3 … endlessly.

How do you schedule these three threads in order to print 1 2 3 1 2 3 …?| Report Duplicate | Flag | PURGE

Salesforce Software Engineer Threads - 0of 0 votes

Answerscreate a grid and show data, they have provided some JSON file for it. we should be able to configure sorting anf fitering for some coumns. paging is also required. we need to make it in pure JS.

- rajansoft1 May 14, 2015 in India| Report Duplicate | Flag | PURGE

Payu Software Engineer JavaScript - 1of 1 vote

AnswersWrite a function which, given two integers (a numerator and a denominator), print the first N digits of a rational number. For example, for 5 / 3 with N=5, the result should be "1.66666". N=2: 1.66

- Dan Shah May 13, 2015 in United States| Report Duplicate | Flag | PURGE

Google Software Engineer - 2of 2 votes

Answers0 1 ?

- .netDecoder May 08, 2015 in United States

? wildcard for 0 or 1

"01?"

010 011

Example:

01?0?

Will produce

01000

01100

01001

01101| Report Duplicate | Flag | PURGE

Google Software Engineer Algorithm - 3of 5 votes

AnswersLook at the sequence below:

- amirtar May 05, 2015 in United States

1, 11, 21, 1211, 111221, 312211, ...

Write a code that receives n and returns the nth element of the sequence. If it gets 4 as input of the method it should return 1211.| Report Duplicate | Flag | PURGE

Google Software Engineer - 0of 2 votes

AnswersThe text of question below is exactly given by Google interviewer. So they are owner of the text and I am just quoting them. I am not the author of the text below:

- amirtar May 05, 2015 in United States

"

Imagine a museum floor that looks like this:

.#.G.

..#..

G....

..#..

G == Museum Guard

# == obstruction/impassable obstacle

. == empty space

Write a piece of code that will find the nearest guard for each open floor space. Diagonal moves are not allowed. The output should convey this information:

2#1G1

12#12

G1223

12#34

You may choose how you want to receive the input and output. For example, you may use a 2-d array, as depicted here, or you may use a list of points with features, if you deem that easier to work with, as long as the same information is conveyed.

"| Report Duplicate | Flag | PURGE

Google Software Engineer Algorithm Ideas Math & Computation - 1of 3 votes

AnswersWe know a string is Palindrome if it is the same reading from both sides. Now we define the following string also Palindrome:

- amirtar May 05, 2015 in United States

A man, a plan, a canal, Panama!

Write a code that returns if an string is palindrome and it should return true for above input. (Without directly saying, I should conclude that I have to only consider alphanumerical characters in a string). In addition, we assume the string is very long and we can not keep a copy of this string or even a copy of preprocessed version of this string. Therefore the result should be returned with the first sweep of the string.| Report Duplicate | Flag | PURGE

Facebook Software Engineer Algorithm String Manipulation - 0of 2 votes

AnswersAdd a third dimension of time to a hashmap , so ur hashmap will look something like this - HashMap<K, t, V> where t is a float value. Implement the get and put methods to this map. The get method should be something like - map.get(K,t) which should give us the value. If t does not exists then map should return the closest t' such that t' is smaller than t. For example, if map contains (K,1,V1) and (K,2,V2) and the user does a get(k,1.5) then the output should be v1 as 1 is the next smallest number to 1.5

- randomCoder1988 May 02, 2015 in United States for Mobile| Report Duplicate | Flag | PURGE

Uber Software Engineer - 3of 3 votes

AnswersThere are N pots. Every pots have some water in it. They may be partially filled. So there is a Overflow Number 0 associated with every pot which tell how many minimum stone pieces are require for that pot to overflow. So if for a pot 0-value is 5 it means minimum 5 stone pieces should be put in that pot to make it overflow. Initially a crow watched those pots and by seeing the water level he anticipated 0-value correctly for every pot ( that is he knew 01 to On). But when he came back in evening he found that every pot is painted from outside and he is not able to know which pot has what 0-value. Crow wants some K pots to overflow so that he can serve his child appropriately. For overflow of pots he need to search for stone in forest( assume that every stone has same size). He wants to use minimum number of stones required to overflow K pots. But only he know the 0-value of pots he doesn't know now which pot has what 0-value. So the task is that in what minimum number of stones he can make K pots overflow in worst case.

- veeru April 29, 2015 in India for Development

Input/Output Specifications Input Specification: 1) A array 0 corresponding to 0-value of N pots {01, 02, On} 2) Number of pots 3) K -value ( number of pots which the crow wants to overflow}

Output Specification: Minimum number of stones required to make K pots overflow in worst case. Or -1 if input is invalid

Example: Let say there are two pots pot 1 has 0 value of 5 , 01= 5 pot 2 has 0 value of 58, 02= 58 Let say crow wants to make one of the pot to overflow. If he know which pot has what 0-value he would simple search for 5 stones and put then in pot 1 to make it overflow. But in real case he doesn't know which pot has what 0-value so just 5 stones may not always work. However he does know that one pot has 0-value S and other has 58. So even in worst case he can make one of the pot overflow just by using 10 stones. He would put 5 stones in one pot if it doesn't overflow he would try the remaining 5 in the other pot which would definitely overflow because one of the pot has 0-value of 5. So the answer for above question is minimum 10 stones even in worst case. Input : Input 1= {5,58} Input 2= 2 Input 3= 1 Output : 10| Report Duplicate | Flag | PURGE

Amazon Software Engineer

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

Open Chat in New Window