## Software Developer Interview Questions

- 0of 0 votes

AnswersHow to find total number of greater number after all number in an array ?

- rahulkumar5july September 18, 2016 in India

Eg. Given array is,

5 3 9 8 2 6

o/p

3 3 0 0 1 0| Report Duplicate | Flag | PURGE

Walmart Labs Software Developer - 1of 1 vote

AnswerYou are given a list of tasks as an integer array, task_costs. Every i-th element of task_costs represents a task and requires task_costs[i] seconds to complete. All tasks listed in the array are independent of other tasks.

- Abhishek.Mathur.CA September 18, 2016 in United States

It is required to finish all the tasks independently and as soon as possible. You are given a single worker robot to start taking the tasks and finish them one at a time. However if you like, you can divide the worker robot in two. Each resulting robot can then be further divided into two and so on. There is a cost, in seconds, of dividing a robot in two, represented by robot_divide_cost.

You can assign an independent task to any available robot, however you can't interrupt or divide a robot while it is working on the assigned task. At the same time you can't assign a task to any robot while its in the process of getting divided.

To keep things simple you can't allow multiple robots to work on the same task. At any given time only one robot can work on a task and finish it. Once any particular robot finishes a task it can't be assigned any further tasks.

Given a list of tasks and cost of dividing a robot, find the least amount of time to finish all tasks.

Input:

3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,360,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600,3600

3600

Expected Output: 25200

Input:

1113,773,824,822,1458,1257,908,1320,780,1016,1066,861,1150,718,1405,738,718,980,1037,946,1121,1349,805,1378,1308,1272,1532,779,875,1392,982,1282,744,723,1033,1067,1158,1071,742,683,678,762,686,1143,862,1231,765,1472,1560,1085

3147

Expected Output: 20040| Report Duplicate | Flag | PURGE

unknown Software Developer - 0of 0 votes

AnswersGiven an array of numbers find the duplicates

- andy.r.nathan September 14, 2016 in United States for Mobile| Report Duplicate | Flag | PURGE

Linkedin Software Developer Algorithm - 1of 1 vote

AnswersSuppose you have a list of Dishes, where each dish is associated with a list of ingredients. Group together dishes with common ingredients.

- andy.r.nathan September 14, 2016 in United States for Mobile

E.g:

Input:

"Pasta" -> ["Tomato Sauce", "Onions", "Garlic"]

"Chicken Curry" --> ["Chicken", "Curry Sauce"]

"Fried Rice" --> ["Rice", "Onions", "Nuts"]

"Salad" --> ["Spinach", "Nuts"]

"Sandwich" --> ["Cheese", "Bread"]

"Quesadilla" --> ["Chicken", "Cheese"]

Output: ("Pasta", "Fried Rice") ("Fried Rice, "Salad") , ("Chicken Curry", "Quesadilla") ("Sandwich", "Quesadilla")

Follow up: What is the time and space complexity?| Report Duplicate | Flag | PURGE

Linkedin Software Developer Algorithm - 0of 0 votes

Answerhow to create a de-duplication engine that acts as a file storage, retrieval, and handling system. It must take some files as inputs, take data from it in chunks of 8 byte size and store it in some efficient data structure of our choice. The data structure should be robust and must not store duplicate chunks. Instead, it has to make a reference to the original chunk that is repeated.

- smtkpr88 September 11, 2016 in India| Report Duplicate | Flag | PURGE

Coupon Dunia Software Developer unix system programmin - 0of 0 votes

AnswersDesign a HTTP response service that will allow sync and async download. What classes would you create and the methods used with paramerters and return types.

- MM September 10, 2016 in United States| Report Duplicate | Flag | PURGE

Facebook Software Developer Object Oriented Design - 2of 2 votes

Answers[redacted]

- tohhubeta September 02, 2016 in United States| Report Duplicate | Flag | PURGE

Google Software Developer Algorithm - 1of 1 vote

AnswersGiven a sparse matrix, implement below two methods:

- starlord September 01, 2016 in United States

void set(int row, int col, int val) /*Update value at given row and col*/

int sum(int row, int col) /*give sum from top left corner to given row, col sub-matrix*/| Report Duplicate | Flag | PURGE

Google Software Developer Algorithm - 1of 1 vote

AnswersA company is looking for algorithm to show item recommendations.

- maksymas August 29, 2016 in United States

If a customer bought A and B items and another buys A item, B should come as recommendations.

There are two types of recommendations based on the connections

1) Two items are strongly connected if a customer buys those items.

2) Two items are weakly connected if each items are strongly/weakly connected to another third item.

Provided the sample input

ABC

10

first:ABC

first:HIJ

sec:HIJ

sec:KLM

third:NOP

fourth:ABC

fourth:QRS

first:DEF

fifth:KLM

fifth:TUV

first, sec, third.. represents the customer names

ABC, HIJ... represents the item codes

For the Input item Id "ABC", since "ABC" is strongly connected to HIJ, DEF, QRS

and whereas ABC is weakly connected to KLM and TUV

the output should be count of strong and weak connection i.e., [3,2]| Report Duplicate | Flag | PURGE

Amazon Software Developer Algorithm - -5of 5 votes

Answersinterview would be easy. For freshers it would be okay

- magesh215 August 17, 2016 in India

for experienced no salary hike is available| Report Duplicate | Flag | PURGE

Nanosoft Technologies - Chennai Software Developer - 0of 2 votes

Answerpair programming example question with code for thoughworks interview

- rahulgoyal030 August 16, 2016 in India| Report Duplicate | Flag | PURGE

ThoughtWorks Software Developer C++ - -2of 2 votes

AnswersDesign unix file system in database.

- mohit.kum85 August 16, 2016 in United States| Report Duplicate | Flag | PURGE

Amazon Software Developer Database - 0of 0 votes

AnswersSuggest a data structure and implement efficient phrase search along with word search in a huge chunk of text.

- novicedhunnu August 14, 2016 in India for N/A| Report Duplicate | Flag | PURGE

Microsoft Software Developer Trees and Graphs - 2of 2 votes

AnswersThere are n+1 loading docks. a permutation of boxes 1->n is placed on the first n. there is a fork that can move one box to an empty location at a time. Give an algorithm to sort then boxes with minimum number of moves.

- ad09 August 05, 2016 in United States

Follow up: minimum distance| Report Duplicate | Flag | PURGE

Google Software Developer Algorithm - 0of 0 votes

AnswersGiven a dictionary and a string, find all the substrings that are valid words in dictionary.

- Pedro July 28, 2016 in United States

I was thinking of a Trie solution but I'm not sure a Trie will work easily to match sub words that begin in the middle of the string.| Report Duplicate | Flag | PURGE

Google Software Developer Algorithm - 0of 0 votes

AnswersGiven an array: 1,2,3 ,5,8,7,6,9,5,7,3,0,5

- sindhu1690 July 27, 2016 in United States

subarry:5,7

Find the subarray in the large array and return the minimum length and index where you can find the subarray. Note: that the subarray may be present in the large array non-contiguous.

In the above case : the answer is length = 2 and

index = 8| Report Duplicate | Flag | PURGE

Microsoft Software Developer Algorithm - 0of 0 votes

AnswersAn unsorted array is given . Find the no of greater elements on right side on current element in array. Find this for every element of array Expected time complexity is lesser then O(n^2)

- knocks July 24, 2016 in United States| Report Duplicate | Flag | PURGE

Amazon Software Developer Algorithm - 0of 0 votes

AnswersA monotonically increasing function F(X) exists. For a given no N , find the value of X when F(X) = N.

- knocks July 24, 2016 in India| Report Duplicate | Flag | PURGE

Amazon Software Developer Algorithm - 0of 0 votes

AnswersGiven a random function with equal probability of getting 1 or 0 ie 50% each. write a custom function which uses the above random function such that your function should return 1 with 75% probability and 0 with 25% probability

- coolcoder3 July 22, 2016 in India| Report Duplicate | Flag | PURGE

Oracle Software Developer Algorithm Problem Solving - 6of 6 votes

AnswersYou are given a matrix with N rows and N columns. Elements in matrix can be either 1 or 0. Each row and column of matrix is sorted in ascending order.

Find number of 0-s in the given matrix.

Example:`0 0 1 0 1 1 1 1 1 Answer: 3 0 0 0 0 Answer: 4`

Update: Expected complexity is O(log(N)). The best I've seen in comments is still O(N).

- emb June 26, 2016 in United States

Update2: Alright, guys, sorry for a bit of trolling. Obviously this is not possible to do faster than O(N). Here is why: take a diagonal (N, 1), (N-1, 2), ... (1, N). Suppose input matrix has all 0's above this diagonal and all 1's under this diagonal. So only diagonal elements vary. Clearly, diagonal elements do not depend on each other. So we have to analyze each diagonal element which is O(N).

Nice job, @gen-y-s :)| Report Duplicate | Flag | PURGE

Google Software Developer Algorithm - 0of 0 votes

AnswerGiven M nodes and at most one outgoing edge from any node. Given Q operations where an operation is either

- lifeenergy999 June 19, 2016 in India

i) 1 Z where Z represent the source node, print the terminal node if a coin travels through edges. In case, if node Z lies in a cycle, print LOOP. 1 is the operation type

ii) 2 Z where Z represents node for which the outgoing edge is removed and 2 is operation type.

Operations are performed in order in which they are given.

M <= 3*10^5, Q <= 3*10^5

Input

First line contains integer M.

Second line contains M integers, where ith integer represents outgoing edge from ith node. If outgoing edge is 0, that means there is no outgoing edge from this node.

Third line contains integer Q followed by Q lines where each line is either 1 Z, or 2 Z where Z is node number. Nodes are 1-indexed.

This question was asked in coding test. Can somebody please help me with this problem with the given constraints?| Report Duplicate | Flag | PURGE

Software Developer Algorithm - 1of 1 vote

AnswersWrite a class to take in a large arbitrary number, also provide a function to increment the number. The number will be passed on as an array of integers.

- pushpinder2751 June 17, 2016 in United States| Report Duplicate | Flag | PURGE

Google Software Developer Algorithm - 0of 0 votes

Answergiven an arraylist of say 50 lac entries and an empty queue, Design a multi-threading bases system which can copy the items in arraylist in a queue parallely

- avidwaj June 12, 2016 in India

How many threads can be spawned based on what criterion ? Basically the interviewer wanted to know how to implement an algorithm where we can design number of threads to be spawned ?| Report Duplicate | Flag | PURGE

Oracle Software Developer design - 0of 0 votes

AnswersWrite a program that takes an integer and prints out all ways to multiply smaller integers that equal the original number, without repeating sets of factors. In other words, if your output contains 4 * 3, you should not print out 3 * 4 again as that would be a repeating set. Note that this is not asking for prime factorization only. Also, you can assume that the input integers are reasonable in size; correctness is more important than efficiency.

- xankar June 07, 2016 in United States

Eg: PrintFactors(12) 12 * 1 6 * 2 4 * 3 3 * 2 * 2| Report Duplicate | Flag | PURGE

Linkedin Software Developer Algorithm - 0of 2 votes

AnswersA robot on a plane has 2 types of commands:

1. move forward by X units (X is integer 0 <= X <= 10000 )

2. rotate by X degrees (X is integer in range [-180, 180] )

A robot looks like`def robot(commands): while True: for command in commands: execute(command)`

Given a list of commands (of size <= 10000) tell if it's possible to build a wall around the robot such that he will never touch it.

Example:

- emb June 06, 2016 in United States`[move(10), rotate(180), move(10)] -> answer is yes [move(10), rotate(45), move(10), rotate(-45), move(10), rotate(45)] - answer is no`

| Report Duplicate | Flag | PURGE

Google Software Developer Brain Teasers - 2of 2 votes

AnswersYou are given a range [first, last], initially white. You need to paint it black.

For this purpose you have a set of triples

[(f, l, cost), ...] - where each triple means that you can paint range [f, l] for `cost` coins (limitations: cost is floating point >= 0, f, l, first, last are integers).

Find minimum cost needed to paint the whole range [first, last] or return -1 if it's impossible

Example:`[first, last] = [0, 5] and set of triples is [[0, 5, 10], [0, 4, 1], [0, 2,5], [2, 5, 1]]`

Clearly the answer is to take [0, 4, 1] and [2, 5, 1] - the total cost will be 2.

Another example:`[first, last] = [0, 5] triples are [[1,4, 10], [2, 5, 6]]`

answer is -1, because it's impossible to color whole range.

- emb June 05, 2016 in United States| Report Duplicate | Flag | PURGE

Google Software Developer Algorithm - 3of 3 votes

AnswersGiven an array of length N and an integer K, sort the array as much as possible such that no element travels more than k positions to its left - an element however can travel as much as it likes to its right.

- testing@123 June 01, 2016 in United States| Report Duplicate | Flag | PURGE

Google Software Developer Algorithm - 1of 1 vote

Answersgiven 2 strings A and B. generate all possible solutions when B is merged in A.

- JerryGoyal May 22, 2016 in India

Ex: A = "hey"

B: "sam"

then solutions are :

heysam,hseaym,hesaym,sahemy etc.

notice that order should be the same for both of strings while merging.| Report Duplicate | Flag | PURGE

Google Software Developer Algorithm - 0of 0 votes

Answers/*

- xankar May 12, 2016 in United States

Prison cell question

In a kingdom there are prison cells (numbered 1 to P) built to form a straight line segment. Cells number i and i+1 are adjacent, and prisoners in adjacent cells are called "neighbors." A wall with a window separates adjacent cells, and neighbors can communicate through that window.

All prisoners live in peace until a prisoner is released. When that happens, the released prisoner's neighbors find out, and each communicates this to his other neighbor. That prisoner passes it on to his other neighbor, and so on until they reach a prisoner with no other neighbor (because he is in cell 1, or in cell P, or the other adjacent cell is empty). A prisoner who discovers that another prisoner has been released will angrily break everything in his cell, unless he is bribed with a gold coin. So, after releasing a prisoner in cell A, all prisoners housed on either side of cell A - until cell 1, cell P or an empty cell - need to be bribed.

Assume that each prison cell is initially occupied by exactly one prisoner, and that only one prisoner can be released per day. Given the list of Q prisoners to be released in Q days, find the minimum total number of gold coins needed as bribes if the prisoners may be released in any order.

Note that each bribe only has an effect for one day. If a prisoner who was bribed yesterday hears about another released prisoner today, then he needs to be bribed again.

Task: find the minimum amount of gold we need to bribe the prisoners so that the chosen prisoners can be released without causing cell destruction.

Input example:

8 cells, 1 prisoner has to be released. The prisoner to be released is the 3rd one.

|1|2|3|4|5|6|7|8|

7 gold coins

another example:

20 cells, 3 prisoners to be released: 3, 6 and 14

|1|2| |4|5| |7|8|9|10|11|12|13| |15|16|17|18|19|20|

release prisoner 3: 19 gold coins

release prisoner 6: 16 gold coins

release prisoner 14: 13 gold coins

release 14: 19 gold coins

release 6: 12 gold coins

release 3: 4 gold coins

input:

number of cells

prisoners that need to be released

output:

least number of gold coins we need to give

*/| Report Duplicate | Flag | PURGE

Amazon Software Developer Brain Teasers

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

Open Chat in New Window