Software Developer Interview Questions
- 0of 0 votes
AnswersUnsorted array and a position ‘P’. Return the element that is likely to come to the given location upon sorting the array. TC in O(n).
- neer.1304 September 04, 2017 in United States| Report Duplicate | Flag | PURGE
Cisco Systems Software Developer Algorithm - 0of 0 votes
AnswerA thief trying to escape from a jail has to cross ‘N’ walls each with varying heights. He climbs ‘X’ feet every time. But, due to the slippery nature of those walls, every times he slips back by ‘Y’ feet. Now the input is given as (N, {H1, H2, H3,….Hn}, X, Y}. Calculate the total number of jumps required to cross all walls and escape from the jail.
- neer.1304 September 04, 2017 in United States| Report Duplicate | Flag | PURGE
Cisco Systems Software Developer Algorithm - 0of 0 votes
Answerstransactions = [
- Pedro September 01, 2017 in United States
{"payee": "BoA", "amount": 132, "payer": "Chase"},
{"payee": "BoA", "amount": 827, "payer": "Chase"},
{"payee": "Well Fargo", "amount": 751, "payer": "BoA"},
{"payee": "BoA", "amount": 585, "payer": "Chase"},
{"payee": "Chase", "amount": 877, "payer": "Well Fargo"},
{"payee": "Well Fargo", "amount": 157, "payer": "Chase"},
{"payee": "Well Fargo", "amount": 904, "payer": "Chase"},
{"payee": "Chase", "amount": 976, "payer": "BoA"},
{"payee": "Chase", "amount": 548, "payer": "Well Fargo"},
{"payee": "BoA", "amount": 872, "payer": "Well Fargo"},
There are multiple transactions from payee to payer. Consolidate all these transactions to minimum number of possible transactions.
HINT: Consolidate transitive transactions along with similar transactions| Report Duplicate | Flag | PURGE
Google Software Developer - 0of 0 votes
AnswersDesign a space shooter program .
- anaghakr89 August 16, 2017 in United States for Nest Labs
Note: The game includes spaceship , bullets and asteroids. Spaceship rotates in 180 degree generating bullets. The position of the bullets gets updated after certain time period every time . No Need to write the code for collision detection
Basic code in expected . Not the entire working code.| Report Duplicate | Flag | PURGE
Google Software Developer - 0of 0 votes
AnswersGiven a list/array of "Assign" trees with integers, operators and variables, return the result of the requested "Result" tree expression.
Example:
- thetinysheep August 13, 2017 in United States"Assign" / \ "x" "+" / \ 2 3 "Assign" / \ "y" "-" / \ 5000 30 "Assign" / \ "z" "*" / \ 50 x "Return" \ "-" / \ z "*" / \ 1 y
| Report Duplicate | Flag | PURGE
Facebook Software Developer Trees and Graphs - 1of 3 votes
AnswersThe array of integers in given . The array indicates nothing but the heights of the cylinders. The robotic arm has two ends-> left and right.
- anaghakr89 August 07, 2017 in United States
The left end points to the left end of the cylinder array and right end searched for the cylinder with least height.
ex:
array = {4,5,6,7,1,2}
left end => index 0
right end =>index 0->n giving index 4 with min height
Now the entire block is rotated by 180 degree.
now the array = { 1, 7, 6, 5, 4, 2}
now the left end moves forward.
and right end will search from left index onwards till the end of the array
so left index = 1
right index => 1-> n giving index 5 as min. height
again do the block rotate .
Write the code for this particular algorithm.
However, there is one condition
1. If there are duplicates in the array then the final order of those duplicates should remain the same.
ex. If the cylinder with height 4 is appearing at index 3 and 5 in the initial array then the cylinder at index 3 should always appear before the one at index 5 in the final array.| Report Duplicate | Flag | PURGE
Google Software Developer - -1of 1 vote
AnswersThe array of integers in given . The array indicates nothing but the heights of the cylinders. The robotic arm has two ends-> left and right.
- anaghakr89 July 31, 2017 in United States
The left end points to the left end of the cylinder array and right end searched for the cylinder with least height.
ex:
array = {4,5,6,7,1,2}
left end => index 0
right end =>index 0->n giving index 4 with min height
Now the entire block is rotated by 180 degree.
now the array = { 1, 7, 6, 5, 4, 2}
now the left end moves forward.
and right end will search from left index onwards till the end of the array
so left index = 1
right index => 1-> n giving index 5 as min. height
again do the block rotate .
Write the code for this particular algorithm.
However, there is one condition
1. If there are duplicates in the array then the final order of those duplicates should remain the same.
ex. If the cylinder with height 4 is appearing at index 3 and 5 in the initial array then the cylinder at index 3 should always appear before the one at index 5 in the final array.| Report Duplicate | Flag | PURGE
Google Software Developer - 1of 1 vote
AnswersGenerate a random number with UNIFORM DISTRIBUTION between [0,n) where n is given and excluded list is given. The randomly generated number should belong to the range [0, n) but should be excluded from the given excluded list. For example, n = 10 and excluded list ={2,3,0} then the random number should be from {1,4,5,6,7,8,9} such that any number from the list {1,4,5,6,7,8,9} has UNIFORM probablility of occuring
- xyz July 31, 2017 in United States for NEST| Report Duplicate | Flag | PURGE
Google Software Developer - 0of 0 votes
AnswersPerform left and right shift on string
- purva7 July 24, 2017 in United States| Report Duplicate | Flag | PURGE
GE (General Electric) Software Developer String Manipulation - 0of 0 votes
AnswersFind max sum of sub array.
- purva7 July 24, 2017 in United States| Report Duplicate | Flag | PURGE
GE (General Electric) Software Developer Dynamic Programming - 0of 0 votes
AnswerImplement stack using a queue.
- purva7 July 24, 2017 in United States| Report Duplicate | Flag | PURGE
GE (General Electric) Software Developer Stacks - 0of 0 votes
AnswersMerge the overlapping intervals.
- purva7 July 24, 2017 in United States| Report Duplicate | Flag | PURGE
Expedia Software Developer Dynamic Programming - 2of 2 votes
AnswersReverse the words in string eg. 'The Sky is Blue'. then print 'Blue is Sky The'.
- purva7 July 24, 2017 in United States| Report Duplicate | Flag | PURGE
Expedia Software Developer String Manipulation - 1of 1 vote
AnswersFind max sum of subarray
- purva7 July 24, 2017 in United States| Report Duplicate | Flag | PURGE
Expedia Software Developer Dynamic Programming - 1of 1 vote
Answersjava program to interchage continous vowels in a string
- kancharlaratna July 10, 2017 in United States
ex:vowels
becomes vewols
continuous becomes cintonouuus| Report Duplicate | Flag | PURGE
Akamai Software Developer - 1of 1 vote
AnswersConsider an implementation of Strings consisting of an array where the first element of the array indicates the length of the String and the next elements represent the value of the ASCII characters in the String. Implement String concatenation and discuss shortcomings of this operation under this implementation of Strings.
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswersSuppose that there exists a service to fetch Facebook posts through an interface defined by you, design the Facebook wall feed.
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 2of 2 votes
AnswersGiven an array of ints and a value X, find wether there are 3 elements in the array such that their sum is X (return true/false).
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswersGiven two vectors that might be sparse, calculate their Dot product. You can assume any data structure to represent the vectors.
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswersGiven a matrix of characters where '_' represents an empty space, 'T' is a tree and 'H' is a house and a coordinate of that matrix, find the sum of the minimum distances from that coordinate to each house when considering that you can move through empty spaces and houses but not through trees.
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswersReverse a linked list.
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswerGiven two tree nodes and the root of a tree, find the distance between both nodes in the tree.
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswersGiven a String that contains parenthesis, remove the least amount of parenthesis from it such that it becomes balanced.
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswersHow would you store very large numbers that can't be store in a regular Integer or BigInteger, and make calculations
- UCJava July 04, 2017 in United States| Report Duplicate | Flag | PURGE
Amazon Software Developer Data Structures - 0of 0 votes
AnswersDesign an application for people to find a place near them where they can join a team to play their favorite sport. Exp. Soccer teams open to join that are scheduled to play at a certain time and place. The application would search for the available teams to join within certain area playing within some given time period,
- UCJava July 04, 2017 in United States| Report Duplicate | Flag | PURGE
Amazon Software Developer Software Design - 1of 1 vote
AnswersYou have N toffee packets, each containing different number of toffees. The number of toffees contained in the ith packet is denoted by ci. You need to put these toffee packets in M boxes such that each box contains at least one toffee packet, and the maximum number of toffees in a box is minimum.
- praveensinghraghav96 July 02, 2017 in India
You can only choose consecutive toffee packets to put in a box.
Input
The first line of the input contains an integer T denoting the number of test cases. The first line of each test case contains two space separated integers N, M denoting the number of toffee packets and the number of boxes respectively. The second line of each test case contains N space separated integers c1, c2, ..., cN where ci denotes the number of the toffees in the ith toffee packet.
Output
For each test case, output a single line containing the maximum number of toffees in a box. Also, output -1 if such an assignment of toffee packets to boxes is not possible.
Constraints
1 ≤ T ≤ 20
1 ≤ N,K ≤ 100000
1 ≤ ci ≤ 1000
Example
Input:
1
4 2
10 3 5 7
Output:
13
Explanation
Below are the possible assignments of toffee packets to boxes.
10 [3 5 7]
10 3 [5 7]
10 3 5 [7]
For minimizing the maximum number of toffees in a box, we choose the second assignment, and hence the output should be 13| Report Duplicate | Flag | PURGE
Directi Software Developer - 0of 0 votes
AnswerAmr bought a new video game "Guess Your Way Out!". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree is located at some leaf node.
- praveensinghraghav96 July 02, 2017 in India
Let's index all the leaf nodes from the left to the right from 1 to 2^h. The exit is located at some node n where 1 ≤ n ≤ 2^h, the player doesn't know where the exit is so he has to guess his way out!
Amr follows simple algorithm to choose the path. Let's consider infinite command string "LRLRLRLRL..." (consisting of alternating characters 'L' and 'R'). Amr sequentially executes the characters of the string using following rules:
Character 'L' means "go to the left child of the current node";
Character 'R' means "go to the right child of the current node";
If the destination node is already visited, Amr skips current command, otherwise he moves to the destination node;
If Amr skipped two consecutive commands, he goes back to the parent of the current node
before executing next command;
If he reached a leaf node that is not the exit, he returns to the parent of the current
node;
If he reaches an exit, the game is finished.
Now Amr wonders, if he follows this algorithm, how many nodes he is going to visit before reaching the exit?
Input
First Line contains T the number of test cases
The next T lines contains 2 integers h, n
Output
Output T lines each containing an integer representing the number of nodes (excluding the exit node) Amr is going to visit before reaching the exit by following this algorithm.
Constraints
1 ≤ T ≤ 10
1 ≤ h ≤ 50
1 ≤ n ≤ 2^h
Example
Input:
1
2 2
Output:
2
Explanation
Example case 1. Amr would visit first root node then root->left node and then go to the root->left->right node which is the exit. hence 2 nodes visited before reaching the exit| Report Duplicate | Flag | PURGE
Directi Software Developer - 0of 0 votes
AnswersYou are walking down the escalator to catch a subway train. The escalator itself moves at a speed of Ve meters per minute. You can walk down the escalator at a relative speed of Vy meters per minute. The length of the escalator is L meters. Trains arrive T minutes apart. Let t be the time between your arrival to the station if you stand still on the escalator and the arrival of the last train before your arrival. Assume that t is a random variable uniformly distributed between 0 and T. Return the probability of catching an earlier train if you choose to walk down the escalator instead of standing still on it.
- praveensinghraghav96 July 02, 2017 in India
Input :
The first line of the input contains an integer Tc denoting the number of test cases. Each test case contains the following 4 lines
Ve - velocity of escalator
Vy - your relative velocity with the escalator
L - length of escalator
T - Time Period of Trains
Output
For each test case, output a single line containing the expected probability having an absolute or relative error less than 10^-6.
Constraints
0 ≤ Tc ≤ 5 * 10 ^ 7
1 ≤ Ve ≤ 1000
1 ≤ Vy ≤ 1000
1 ≤ L ≤ 10 ^ 5
1 ≤ T ≤ 10 ^ 6
Example
Input:
2
10
10
20
2
10
10
100
4
Output:
0.5
1.0
Explanation
Example case 1. If you stand still, it'll take you 20/10 = 2 minutes to reach the bottom of the escalator. If you choose to walk, it'll make you 20/(10+10) = 1 minute. In the second case you save 1 minute and in 50% of the cases it'll allow you to catch an earlier train.
Example Case 2. Here, if you choose to walk instead of stand still, you will save 5 minutes and you will certainly be guaranteed to catch an earlier train.| Report Duplicate | Flag | PURGE
Directi Software Developer - 3of 3 votes
AnswersFind out if the given string forms a valid lottery number.
- AnonD June 09, 2017 in United States
- A valid lottery number contains 7 unique digits between 1 and 59.
e.g.
4938532894754 (yes) -> 49 38 53 28 9 47 54
1634616512 (yes) -> 1 6 34 6 16 51 2
1122334 (no)| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswersThere are three row of houses. There are N houses in each row. Each house can be painted with three colors: red, blue and green. The cost of painting each house with a certain color is different. You have to paint all the houses with following constaints
- jmincoder2 May 16, 2017 in United States
No two adjacent houses in a row have the same color.
Houses in a column have three different colors
You have to paint the houses with minimum cost. How would you do it?
Note: The cost of painting house 1 red is different from that of painting house 2 red in any row. Each combination of house and color has its own cost.| Report Duplicate | Flag | PURGE
Amazon Software Developer Algorithm