## Algorithm Interview Questions

- 1of 1 vote

AnswerGiven an array and threshold value. The threshold represents the maximum length of subarrays that may be created. Each subarray created has a cost equal to the maximum integer within the subarray. Partition the entire array into subarrays no longer than the threshold and do it at minimum cost. The subarrays are to be chosen from contiguous elements and the given array must remain in its original order. Write a function to return an integer that denotes the minimum cost to partition the array.

- sticker01 September 23, 2018 in United States

For more clarification, here are the test cases.

1. Array: [1,2], threshold: 1.

we divide the array to {(1),(2)} Total cost is 1+2 = 3

2. Array: [1,5,2], threshold: 2.

we divide the array to {(1),(5),(2)} with total cost 1+5+2 = 8. OR

we divide to {(1,5),(2)} with total cost 5+2 = 7 OR

we divide to {(1),(5,2)} with total cost 1+5 = 6.

Of these minimum total cost is 6. So the ans is 6 with subarrays as {(1),(5,2)}| Report Duplicate | Flag | PURGE

Algorithm - 0of 0 votes

AnswersA company wants to fly in a total of 100 candidates for the interview. The company has two office location, one in NY and other in SF and max capacity at each location is 50 candidates. You are given the cost it incurs to fly in each candidate to NY and SF.

`[500, 300],[540, 600],[550, 600],[300, 50]..so on`

Write an algorithm for the minimum total cost?

- nishug001 September 22, 2018 in United States| Report Duplicate | Flag | PURGE

Bloomberg LP Software Engineer Algorithm - 0of 0 votes

AnswersGiven 3 unsorted arrays A, B and C you need to find all possible combinations such that A[i] + B[j] = B[k] + C[l].

- venkataratnamkumar7777 September 22, 2018 in United States| Report Duplicate | Flag | PURGE

Walmart Labs SDE1 Algorithm Arrays - 1of 1 vote

AnswersLets there are n stores.

- sam September 18, 2018 in United States

A customer order x items. All the stores might not have all the items from the order list. So find the store/combination of stores that can serve the order request such that the set that contain least number of stores is selected so that there are lesser number of shipments.| Report Duplicate | Flag | PURGE

Software Developer Algorithm - 0of 0 votes

AnswersPascal Triangle Hockey Stick Identity?

- Pearl September 16, 2018 in United States| Report Duplicate | Flag | PURGE

Algorithm - 0of 0 votes

AnswersGiven an array of negative and positive integers, find the biggest sum of a sub-array.

- asiftasleem September 12, 2018 in United States| Report Duplicate | Flag | PURGE

Service Now Staff Engineer Algorithm - 0of 0 votes

AnswersGiven an array of integers and a target. Find the two array elements if they are summed up, will result in the target.

- asiftasleem September 12, 2018 in United States| Report Duplicate | Flag | PURGE

Service Now Staff Engineer Algorithm - 0of 0 votes

AnswersFind 2nd duplicate in an array

- interviewquestionsseeker September 07, 2018 in United States| Report Duplicate | Flag | PURGE

Akamai Software Engineer Algorithm - 0of 0 votes

AnswersGiven 2 sets of words. Find the words in 2nd set that begin with any word in the 1st set.

- interviewquestionsseeker September 07, 2018 in United States| Report Duplicate | Flag | PURGE

Akamai Software Engineer Algorithm - 0of 0 votes

AnswerLargest Sum Contiguous Subarray

- interviewquestionsseeker September 07, 2018 in United States| Report Duplicate | Flag | PURGE

Akamai Software Engineer Algorithm - 0of 0 votes

AnswersGiven integer m and n where n is odd, for all mxn matrixes that consist of 0 and 1, find the one that has max count of 1s and meets following conditions:

- akak18183 August 31, 2018 in United States

1. All 0s are connected;

2. All 1s are adjacent to at least one 0 (Adjacent includes diagonal line adjacent, 8 directions);

3. maxtrix[m-1][n/2] = 0.

Example :

Input: m=2, n=3

Output: [[1,1,1],[1,0,1]]

Follow up:

Given another list of 'blocked' points. Matrix will set those points to -1 and you cannot change that. Solve the problem again.| Report Duplicate | Flag | PURGE

unknown Software Engineer Algorithm - 0of 0 votes

AnswersWhat is idempotence and why is it useful for API design? (~2-6

- ruta.gadgil August 31, 2018 in United States for Penny

sentences)| Report Duplicate | Flag | PURGE

CreditKarma Software Engineer Algorithm - 0of 0 votes

AnswersLooking at this function, what bugs do you see or concerns do you have

- ruta.gadgil August 31, 2018 in United States for Penny

about its functionality? You can assume the models are correctly

{{defined, the schema is correct, etc. (~1-3 sentences)

def send_email_to_user_once!(to_user_id:, type:, subject:, body:)

user = User.find(to_user_id)

return if UserEmailLog.where(user_id: user.user_id, email: type).exists?

send_email(to: user.email, subject: subject, body: body)

UserEmailLog.create!(user_id: user.user_id, email: type)

end

def send_email(to:, subject:, body:)

# Makes a blocking network request to Amazon Simple Email Sender

# to send an email. Returns nothing in all cases.

# See this link for more info if you need it.

end}}| Report Duplicate | Flag | PURGE

CreditKarma Software Engineer Algorithm - 0of 0 votes

AnswersWhat does this Javascript ES6 function do and how is it useful? If you

- ruta.gadgil August 31, 2018 in United States for Penny

had to give the function a name, what would it be? (~1-2 sentences)

{{

function operate(l, s, callback) {

a = s

for (let i = 0; i < l.length; i++) {

a = callback(a, l[i])

}

return a

}

}}| Report Duplicate | Flag | PURGE

CreditKarma Software Engineer Algorithm - 5of 5 votes

AnswersYou are given a campus map with the Google buildings, roads and Google

bikes. You have to help the employee find the nearest Google bike.

Campus map:

- john August 29, 2018 in United States`. - Free path/road # - Building B - Google bike Employee location - (x, y) - (1, 2) . . . . . # . . E . . # # # # # . # . B . . . . . . . . . B`

| Report Duplicate | Flag | PURGE

Google Software Engineer Algorithm - 0of 0 votes

AnswersFor a given amount of currency, find the minimum set of bills. The currency set is the following: 0.01, 0.05, 0.1, 0.25, 1, 5, 10, 20, 50, and 100. For example, for 21.28, 1 20 bill, and 1 1 bill, and 1 0.25 bill and 3 0.01 bills.

- fz August 09, 2018 in United States| Report Duplicate | Flag | PURGE

Software Developer Algorithm - 0of 2 votes

AnswersWhat is the best way to generate first N primes? (not primes up to N but first N primes)

- koustav.adorable July 22, 2018 in United States for Amazon Prime| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

Answer**Game of Bits**

- harshit.knit July 19, 2018 in India

Yale and Xavier are playing a game with numbers. Each round of the game starts with a number given to them by Zita, Yale’s little sister.

The number n is expressed as a binary integer with p bits

For every round, Xavier gets the first move.

The game came consists of moves performed by Yale and Xavier alternately.

The mth move of the game involves performing these operations on the number:

Toggling the mth bit (numbering of bits starts from left) of the number.

Toggling the left adjacent bit of m (if such a bit exists) if it is equal to the mth bit before toggling in step 1; otherwise keep it as is.

Toggling the right adjacent bit of m (if such a bit exists) if it is equal to the mth bit before toggling in step 1; otherwise keep it as is.

This modification of the number goes on until all p moves are made. If the modified number (as a result of all the operations) is

equal (or a distance one away) from the original number, then the person who made the last move wins the round; otherwise the other one wins the round.

**Note:**

The number given to them is converted to its binary form and represented with the help of minimum number of bits.

The numbering for the bits starts from the leftmost bit.

**Constraints**

1<=r<=10^6

1<=n<=10^6, where n is the number given by Zita in any round

**Input Format**

The first line contains a number, r, denoting the number of rounds in the game.

This is followed by r lines, where the ith line contains the number given by Zita for the ith round.

**Output Format**

The output of the problem has r lines, where the ith line contains the winner of ith round as X if Xavier wins ith round or Y if Yale wins the ith round.

**Sample Input**

1

11

**Sample Output**

Y

**Explanation**

11 is represented as 1011 using minimum number of bits in binary.

When Xavier makes the first move, it becomes 0011.

Then Yale makes the 2nd move and it becomes 1111.

After the third move made by Xavier, it becomes 1000.

After the last move by Yale, it becomes 1011 which is 11 in decimal.

The last move was made Yale and the modified number is equal or adjacent to 11,

therefore, Yale wins this round.| Report Duplicate | Flag | PURGE

ThoughtWorks Software Engineer / Developer Algorithm - 0of 0 votes

AnswerYou have been given a string and a number. You need to find the longest common suffix between string and substring(0 to number)

- sandeepmnit35 July 10, 2018 in United States

Example : String = "ababa"

Number is 3

Take a substring from 0 to 2 which is aba

now find the longest matching suffix between "ababa" and "aba"| Report Duplicate | Flag | PURGE

Computer Scientist Algorithm - 1of 1 vote

AnswersI don't remember perfectly the question, but it was like this

- mmoshikoo July 10, 2018 in Israel

Given a list of 100 songs on your cell phone, find a way for each user to hear the songs without repeating songs, you need to use an algorithm that uses shuffle for songs.| Report Duplicate | Flag | PURGE

Microsoft Software Developer Algorithm - 2of 2 votes

AnswersGiven 2 strings representing very large numbers (these are not representable as a BigInteger or other various type) write a method for adding the two numbers and returning their sum.

- Scott.T.Rogers July 06, 2018 in United States| Report Duplicate | Flag | PURGE

Facebook Senior Software Development Engineer Algorithm - 0of 0 votes

AnswersDesign and implement a interest matching algo, to match people according to their interests in a particular area.

- ANONU July 06, 2018 in United States

Suggest a score based on their interests. And rank matchings accordingly.| Report Duplicate | Flag | PURGE

Zynga Software Engineer Algorithm System Design - 3of 3 votes

AnswersIn a Binary maze with 0 and 1, 0 is the valid cell to which we can travel and 1 means that the cell is blocked. Given source and destination. We have to find-

- richa.cseit July 03, 2018 in India

1. IF path exists, if yes, find shortest path.

2. If we are given a chance to toggle single cell from 1 to 0 , which cell you will toggle so that you will surely get the shortest path.| Report Duplicate | Flag | PURGE

Uber SDE-3 Algorithm - 0of 0 votes

Answersset of locations on the map. Example, 4 places in zone 1. 2 places in zone2, 1 place in zone3 and 2 in zone4. 2 aircraft are assigned, A1, A2. A1 can fly faster. A2 is slower but farther than A1. Each day A1 can visit one location in any zone whereas A2 can visit 2 locations in any zone. what is the optimized number of visits by A1 and A2 at the end of 30 days.

- Geetha June 24, 2018 for Australia| Report Duplicate | Flag | PURGE

Capgemini Dev Lead Algorithm - 0of 0 votes

AnswersGiven a wall, which is made up of two types of bricks (Porus / opaque ). Porus bricks allow water pass through them. Opaque won't. Find whether water reaches to ground, if there is any rainfall.

- gopi.komanduri June 11, 2018 in India for Office

Water can flow from top to bottom, diagonally, horizontally as well. Only flowing from bottom to top is not possible.| Report Duplicate | Flag | PURGE

Microsoft SDE-3 Algorithm Arrays Brain Storming Coding Data Structures Dynamic Programming Problem Solving Programming Skills - 0of 0 votes

AnswerGiven an infinitely large array and every element has tags associated with them, and there are about 10,000 tags (say) then sort the given array to get all tag-0’s first, tag-1’s next and so on in O(n).

- Ankita June 10, 2018 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 0of 0 votes

Answerswater capacity in a histogram

- TonyStark June 08, 2018 in India

what is the capacity if an array value becomes 0 - which will make the water to flow off the histogram| Report Duplicate | Flag | PURGE

Algorithm - -1of 1 vote

AnswersReverse a linked list

- James666 June 06, 2018 in United States| Report Duplicate | Flag | PURGE

Google Software Engineer Algorithm - 0of 0 votes

AnswersFind Duplicate number from a huge amount of data which cannot fit in the memory.

- CodeNinja June 03, 2018 in United States| Report Duplicate | Flag | PURGE

Microsoft Software Developer Algorithm

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

Open Chat in New Window