Software Developer Interview Questions
- 0of 0 votes
Answersconvert a number m to n with minimum operations. The operations allowed were -1 and *2.
- Rahul Sharma January 13, 2016 in United States
For Eg : 4 and 6. Answer is 2.
1st operation : -1 -> 4-1 = 3.
2nd operation : * -> 3 * 2 =6.| Report Duplicate | Flag | PURGE
Software Developer Algorithm - 0of 2 votes
AnswersHow many Fibonacci numbers exists less than a given number n.Can you find a function in terms of n , to get the number of fibonacci number less than n.
- Rahul Sharma January 13, 2016 in United States
Example : n = 6
Answer: 6 as (0, 1, 1, 2, 3, 5)| Report Duplicate | Flag | PURGE
Google Software Developer Algorithm - 0of 0 votes
AnswerA delivery boy wants to deliver some items on his way from office to home. You need to find the optimized path he should take from office to home and deliver all his deliveries on his way.
- mirinda January 09, 2016 in India
It is 101 X 101 grid. Office, home , delivery points are represented via coordinated (x,y) where 0 <= x <= 100, 0 <= y <= 100.
distance between two points (x1, y1) and (x2,y2) is computed as |x1 - x2| + |y1 - y2|
You need to find the optimized path from office to home covering all delivery locations and return the optimized path length as output.
You will be given the input in the 2 lines
first line - N (no. of delivery locations)
second line - (x,y) coordinates of office, followed by home, followed by all N delivery locations.
3
0 0 100 100 20 30 50 50 70 70
output: The length of the optimized path taken.
For above input, the output is 200| Report Duplicate | Flag | PURGE
Samsung Software Developer Problem Solving - 8of 8 votes
AnswersSuppose you have ten million data in a array where each data should be 15 in length. Some of the data length changed somehow. How do you find out which data are distorted.
- pcbabu January 05, 2016 in United States| Report Duplicate | Flag | PURGE
Software Developer - 0of 0 votes
AnswersCounting the number of digits before and after the decimal point without using string ( using double data type).
- Rohit Hajare December 29, 2015 in India| Report Duplicate | Flag | PURGE
Software Developer C - 0of 0 votes
Answers
- Desi Joe December 22, 2015 in United Statesinterface RangeContainerFactory { /** * builds an immutable container optimized for range queries. * Data is expected to be 32k items or less. * The position in the “data” array represents the “id” for that instance * in question. For the “PayrollResult” example before, the “id” might be * the worker’s employee number, the data value is the corresponding * net pay. E.g, data[5]=2000 means that employee #6 has net pay of 2000. */ RangeContainer createContainer(long[] data) } /** * a specialized container of records optimized for efficient range queries * on an attribute of the data. */ interface RangeContainer { /** * @return the Ids of all instances found in the container that * have data value between fromValue and toValue with optional * inclusivity. The ids should be returned in ascending order when retrieved * using nextId(). */ Ids findIdsInRange(longfromValue, long toValue, boolean fromInclusive, boolean toInclusive) } /** * an iterator of Ids */ interface Ids { /** * return the next id in sequence, -1 if at end of data. * The ids should be in sorted order (from lower to higher) to facilitate * the query distribution into multiple containers. */ static final shortEND_OF_IDS = -1 short nextId() } Validation: Your implementation should pass the following simple JUnit test before you start tuning for performance with volume data: public class RangeQueryBasicTest { private RangeContainer rc @Before public void setUp(){ RangeContainerFactory rf = new YourRangeContainerFactory() rc = rf.createContainer(new long[]{10,12,17,21,2,15,16}) } @Test public void runARangeQuery(){ Ids ids = rc.findIdsInRange(14, 17, true, true) assertEquals(2, ids.nextId()) assertEquals(5, ids.nextId()) assertEquals(6, ids.nextId()) assertEquals(Ids.END_OF_IDS, ids.nextId()) ids = rc.findIdsInRange(14, 17, true, false) assertEquals(5, ids.nextId()) assertEquals(6, ids.nextId()) assertEquals(Ids.END_OF_IDS, ids.nextId()) ids = rc.findIdsInRange(20, Long.MAX_VALUE, false, true) assertEquals(3, ids.nextId()) assertEquals(Ids.END_OF_IDS, ids.nextId()) } } FAQ Can't we just use a B-Tree/ NavigableMap/HashTable/BinarySearch/Lucene... Sure, if you want. But there are a number of things we'd like to achieve: ● The container will be in memory and will need to hold lots of data, so we'd like it to be as space efficient as possible, but not to the extent where speed is significantly compromised. Speed is king, memory/disk can be purchased. ● Since we hate collecting garbage, we need to be careful about memory allocation during a query, as my grandmother told me, "allocate not, gc not". ● Code should be clear and understandable. ● The rough order of trade off to consider for this case is: search performance, efficient usage of memory, simplicity and maintainability of the code These objectives are often at odds - we'd like to explore what's possible.
| Report Duplicate | Flag | PURGE
unknown Software Developer Algorithm - 0of 0 votes
AnswersTwo files are there file1.txt, file2.txt - both have some random names.
- Rajarathinam Antony December 08, 2015 in India
Like,
file1.txt file2.txt
---------- -----------
Raja Uthaya
Antony Karthi
Christopher Raja
Manickam Antony
Veeramani
Assume file1.txt can have more names(whole database of names), file2.txt has some selected names
You have to display what are all the mismatching items from file1.txt
Need efficient algorithm to do this| Report Duplicate | Flag | PURGE
Honeywell Software Developer Algorithm - 29of 29 votes
AnswersGiven string say ABCGRETCABCG and substring length let us take length as 3, find the count of possible substrings, for example in above string ABC => 2 and BCG => 2 , where CGR and other 3 word length substrings has a count of 1.
- softwaregeek December 08, 2015 in India for Not known| Report Duplicate | Flag | PURGE
Linkedin Software Developer Algorithm - 0of 0 votes
AnswersGiven a set of numbers find if a triplet can form a triangle a+b > c , b+c > a and c+a > b. The result to display all possible combinations of triplets. [ 10 5 3 4 7 1] [5,3,4 ] is one possible triplet and there can be many more.
- softwaregeek December 08, 2015 in India for Not known| Report Duplicate | Flag | PURGE
Linkedin Software Developer Algorithm - -1of 3 votes
AnswersA frog has to cross the river from one end to another end. river has stones in between randomly where frog can jump. frog can't jump into the river. problem is that will frog ever reach other end with following conditions?
- anuprao85 December 01, 2015 in United States for Office
1. frog allow to do same jump as previous jump. or
2. frog allow to jump 1 more as previous jump. or
3. frog allow to jump 1 less as previous jump.
consider river as Boolean Array. Stone is a element in array where value is true .| Report Duplicate | Flag | PURGE
Microsoft Software Developer Data Structures - 0of 0 votes
AnswersArray with distinct elements is given to you. write an API to return max selected ZIG ZAG array length.
- siva.sai.2020 November 23, 2015 in -
Zig Zag array can start with either '<' or '>'. Below two are valid Zig Zag arrays.
a<b>c<d>e<f
x>y<z<l>k
Note: you may need to skip some elements while selecting Max Zig Zag array. But you should not change array order(swapping and sorting not allowed).
-----------
Zig Zag array examples
Test Case1:
I/P : { 1,42,59,43,68,44 };
O/P: return 5 (Selected ZIG ZAG array 1 < 42 > 43< 68 > 44)
Test case2:
I/P: { 100,42,54,2,5 };
O/P: return 5 (slected ZIg Zag array 100> 42 <54>2 < 5)
Test case 3:
I/P: { 1,42,54,20,1 };
O/P: return 3 {slected Zig zag array 1<42>20}| Report Duplicate | Flag | PURGE
Software Developer - 0of 0 votes
AnswerGiven a string of numbers separated by spaces figure out whether or not you can arrive at 42 with the numbers using only addition, subtraction, and multiplication using java or javascript
- jsduder November 21, 2015 in United States| Report Duplicate | Flag | PURGE
Service Now Software Developer Algorithm - 0of 0 votes
AnswersDesign auto complete for booking.com
- Qasim November 12, 2015 in Netherlands| Report Duplicate | Flag | PURGE
Booking.com Software Developer System Design - 2of 2 votes
AnswersWrite a function to test if the given set of brackets are balanced or not. e.g. {{}}{)([][]
- Qasim November 12, 2015 in Netherlands| Report Duplicate | Flag | PURGE
Booking.com Software 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 - 0of 0 votes
AnswersCount the Mines Problem:
- jsduder October 19, 2015 in United States
Your program will first read an integer N from stdin.
Then it will then read N lines of N integers separated by spaces.
Each integer in this Grid will be either 1 or 0.
The program then outputs an N x N Grid where each Grid element represents the number of 1's surrounding that element, (excluding the element itself).
For (column, row) = (0, 0), surrounding element indices are (0,1) (1,0) and (1,1).
Similarly for (1,1), surrounding element indices are (0,0) (0,1) (0,2) (1,0) (1,2) (2,0) (2,1) and (2,2).
Constraints:
Your output lines should not have any trailing or leading white space
Maximum Dimension of Grid = 1000 x 1000
Example Input:
"3 0 1 0 0 0 0 1 0 0"
Expected output:
1 0 1
2 2 1
0 1 0| Report Duplicate | Flag | PURGE
xyz Software Developer Algorithm - 0of 0 votes
Answersadd 2 huge numbers represented by linked list. Each linked list element represents a 4 digit number:
- capricornkmu October 17, 2015 in United States for OpenStack
linked list1 : 8798 -> 8765 -> 1243 -> 9856 -> 8888 -> 0914
linked list 2: 8710 -> 5634 -> 1276 -> 8123 -> 1354 -> 9876
output: ................-> ............. ..-> 7980->0243 -> 0790| Report Duplicate | Flag | PURGE
Ebay Software Developer C - 0of 0 votes
Answersdifference between shared tree and source specific tree in multicast
- capricornkmu October 17, 2015 in United States for OpenStack| Report Duplicate | Flag | PURGE
Ebay Software Developer Network - 0of 0 votes
Answerswrite a program to validate a IPV4 address
- capricornkmu October 17, 2015 in United States for OpenStack| Report Duplicate | Flag | PURGE
Ebay Software Developer C - 0of 0 votes
AnswersGiven an array of positive, unique, increasingly sorted numbers A, e.g. A = [1, 2, 3, 5, 6, 8, 9, 11, 12, 13]. Given a positive value K, e.g. K = 3. Output all pairs in A that differ exactly by K.
- simplysou October 06, 2015 in United States
e.g. 2, 5
3, 6
5, 8
6, 9
8, 11
9, 12
what is the runtime for your code?| Report Duplicate | Flag | PURGE
Facebook Software Developer - 3of 3 votes
AnswersDesign Live comments. If your facebook.com homepage is open with bunch of feeds and if someone comments on those feeds, the comments should automatically show up in facebook.com home page without refreshing the page. Feeds could be a simple status update by a friend, post in a group, post by a person you're following, post in a page you've liked etc.
- Rejected September 29, 2015 in United States
Few things what they are looking for -
1. How do you solve it initially and how do you scale it?
2. How do you scale push model in-case if you choose PUSH model to solve it?
3. If push cannot scale how do you solve it?
4. How pull model solves it?
5. When will you use push vs pull?| Report Duplicate | Flag | PURGE
Facebook Software Developer Software Design - 1of 1 vote
AnswersHadoop architecture:
- Maniac87 September 20, 2015 in United States
How would you deisgn a Craiglist based architecture ?
What hadoop components you would use. Given the user can search for a car and the car listings get updated frequently. How would you design the craglist system. What database you would use and how would you process the data ?| Report Duplicate | Flag | PURGE
Software Developer System Design - 1of 1 vote
Answers3. Implement a function that returns the i-th most popular item sold at Amazon. You cannot rely on any libraries.
- laurentr September 18, 2015 in United States
class Item {
String itemId;
int quantitySold;
}
/**
* Find the ith most popular item in the list.
*/
String find(List<Item> items, int i) {
// your code goes here
}| Report Duplicate | Flag | PURGE
Amazon Software Developer - 1of 1 vote
Answers2. Suppose 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, down, right or left. Diagonal movement is not allowed.
- laurentr September 18, 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
Example #3
Input
0 0 1 1 1
0 1 0 0 0
0 1 1 1 1
start: 0,0
end: 2,1
Output
False
class Position {
final int x, y;
public Position(final int x, final int y) {
this.x = x;
this.y = y;
}
}
boolean pathExists(int[][] puzzle, Position start, Position end) {
// your code goes here
}| Report Duplicate | Flag | PURGE
Amazon Software Developer - 0of 0 votes
Answers1. Write a function that removes the duplicate of a collection of numbers and returns the number of elements remaining in the collection after the duplicates have been removed. You must ensure that duplicates are actually removed from the list.
- laurentr September 18, 2015 in United States
Example #1
Input
{1, 1, 5, 3, 8, 3, 7, 32, 32}
Output
6
Example #2
Input
{21, 10, 24, 2, 21}
Output
4
int removeDuplicates(List numbers) {
// your code goes here
}| Report Duplicate | Flag | PURGE
Amazon Software Developer - 0of 0 votes
AnswersProblem:
- Yev September 16, 2015 in United States for Anti-money laundering
8 balls, where 7 have equal weight, one does not. Find minimum times to use a scale to find ball that is not equal weight.
Interviewer answer: weight 6 balls. Choose balls from lighter side. Total two attempts. This is the average case but not the best case.
This is not true in all cases and the interviewer did not see this...
Best case:
Pick two balls. One may weight less, so the lighter ball is found with one attempt. This is the best case.
Worst case: If first two balls are equal, weight 6 balls. Choose balls from lighter side. Weight again. Total three attempts.| Report Duplicate | Flag | PURGE
BMO Harris Bank Software Developer Algorithm - 12of 12 votes
AnswersGiven a string which only contains lowercase. You need delete the repeated letters only leave one, and try to make the lexicographical order of new string is smallest.
- lxfuhuo September 09, 2015 in -
i.e:
bcabc
You need delete 1 'b' and 1 'c', so you delete the first 'b' and first 'c', the new string will be abc which is smallest.
ps: If you try to use greedy algorithm to solve this problem, you must sure that you could pass this case:
cbacdcbc. answer is acdb not adcb
I can't solve this problem well and the interviewer said that you can scan the string twice. First scan is do some preprocess, and the second is to get the answer, but I really can't come up this idea.| Report Duplicate | Flag | PURGE
Google Software Developer Algorithm - 8of 8 votes
AnswersYou are given a list of n float numbers x_1, x_2, x_3, ... x_n, where x_i > 0.
- emb September 04, 2015 in United States
A traveler starts at point (0, 0) and moves x_1 metres to the north, then x_2 metres to the west, x_3 to the south, x_4 to the east and so on (after each move his direction changes counter-clockwise)
Write an single-pass algorithm that uses O(1) memory to determine, if the travelers path crosses itself, or not (i.e. if it's self-intersecting)
e.g.
2 1 1 2 -> crosses
1 2 3 4 -> doesn't cross| Report Duplicate | Flag | PURGE
Google Software Developer Algorithm - 0of 2 votes
AnswersYou have given an array and you want to find an integer k so that the sum of the distances from k to each of the n integers is minimized. Define distance between two integers a and b as |a−b|3.
- pbox August 26, 2015 in India| Report Duplicate | Flag | PURGE
Cisco Systems Software Developer - 2of 2 votes
AnswersA multiset or a bag is a collection of elements that can be repeated. Contrast with a set, where elements cannot be repeated.
- ersegun August 20, 2015 in Netherlands
Multisets can be intersected just like sets can be intersected.
Input :
A = [0,1,1,2,2,5]
B = [0,1,2,2,2,6]
Output :
A ∩ B = C = [0,1,2,2]
Input :
A = [0,1,1]
B = [0,1,2,3,4,5,6]
Output
A ∩ B = C = [0,1]
Write a function to find the intersection of two integer arrays in that way ?| Report Duplicate | Flag | PURGE
Booking.com Software Developer String Manipulation