Software Engineer / Developer Interview Questions
- 5of 5 votes
AnswersGiven an array of 0s and 1s, find out:
- HauntedGhost March 05, 2013 in United States
1. all the subsequences where number of 0s = number of 1s
2. max length subsequence where number of 0s = number of 1s
Update:
We need to find subarrays, not subsequences. Sorry for the confusion.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 5of 5 votes
Answersdesign a system to return an unique ID for each request. For most of requests, the ID value should increase as time goes, the system should handle 1000 requests per second at least.
- codingfunnyguy December 04, 2013 in United States
timestamps alone is not valid since there might be multiple requests with same timestamps.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer System Design - 5of 5 votes
AnswersWe have a day to work and we have different kinds works do to which has start-time and end-time. We have to choose the different works so that we can achieve the maximum number of minutes in a day to work. Chosen works should not overlaps to each other.
- Rahul August 22, 2013 in India
Ex-1:
Start-Time End-Time
W1: 6:00 9:30
W2: 9:00 12:30
W3: 12:00 14:30
W4: 10:00 10:30
W5: 11:00 13:30
Solution: W1 + W4 + W3(or W5)
Ex-2:
Start-Time End-Time
W1: 6:00 8:30
W2: 9:00 11:00
W3: 12:30 14:00
W4: 8:00 9:00
W5: 10:30 14:00
W6: 9:00 11:30
Solution : W1 + W6 + W3 = 390min| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 5of 5 votes
AnswersWrite the code for a change vending machine.
- Java Coder October 12, 2008| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 5of 5 votes
AnswersWhat is the difference between a class method and an instance method?
- Mauricio.Malf February 21, 2013 in Netherlands| Report Duplicate | Flag | PURGE
Booking.com Software Engineer / Developer Object Oriented Design - 5of 5 votes
AnswersAsked me to write an API. Then ask:
- joyfeng November 19, 2015 in United States
Consider how the API could support 3rd party applications which need to perform some logic based on the structure and content of a filter in a type-safe manner.| Report Duplicate | Flag | PURGE
unknown Software Engineer / Developer Java - 5of 0 votes
AnswersGive an efficient algorithm to solve this problem. Given "N" files as input, find the common text fragments that occurs in all the files in input and remove them from the files.
- Anonymous September 16, 2008
(A fragment is a piece of text that has at least 3 words)
E.g.
Input
=====
File1
------
It is snowing and I want to drive home.
File2.txt
----------
It is snowing and I want to go skiing.
File3.txt
----------
It is hot and I want to go swimming.
Output
=======
Out.File1.txt
---------------
It is snowing drive home.
Out.File2.txt
-----------------
It is snowing go skiing.
Out.File3.txt
----------------
It is hot go swimming.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 5of 0 votes
Answersfind max number of repetitions in an array.like {2,3,4,5,2,3,2} max repeat is 2. optimize it for space then in time.
- newguy September 01, 2008| Report Duplicate | Flag | PURGE
NVIDIA Software Engineer / Developer Coding - 5of 0 votes
AnswersFind the largest prime factor of a number
- Aryan September 30, 2008| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer - 4of 14 votes
AnswersGiven two aligned sequences `a` and `b`. Write a function "findCommon", that finds the longest substring of the longer sequence that align to the smaller sequence in such a way that the alignment length (matching length) can be maximized. Sequences initially were of different lengths but the smaller one is padded with hyphen ('-') after alignment to make it equal to the longer sequence. The length of longer sequence is known in advance (m, which is same for the smaller padded sequence). The output is always the subsequence of the longer string.
- mary.kindall November 19, 2013 in United States
The total number of such operations to be done is in billions.
findCommon(a, b, m)
Example 1:
a = ------bixg--
b = xxxxxxbi-gzz
m = 12
output: big
Example 2:
a = xxxxxxbxigxx
b = ------b-ig--
m = 12
output = bxig
Example 3:
a = bigxxxxxxxxx
b = bi-x--------
m = 12
output = bigx| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 4of 10 votes
AnswersSuppose we are given a set L of n line segments in the plane, where the endpoints of each
- polo November 01, 2014 in United States
segment lie on the unit circle x^2 + y^2 = 1, and all 2n endpoints are distinct. Describe
and analyze an algorithm to compute the largest subset of L in which no pair of segments
intersects.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 4of 10 votes
AnswersA man goes to a hardware shop and asks for price of an item. The shop keeper replies that the item is "one for $1".
- careercupuser May 19, 2014 in United States
The man gives the shop keeper "$3 for 600". What did the man buy for his newly painted house?| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Brain Teasers - 4of 8 votes
AnswersDesign an algorithm that, given a list of n elements in an array, finds all the elements that appear more than n/3 times in the list. The algorithm should run in linear time ( n >=0 )
- Aashish June 27, 2012 in India
You are expected to use comparisons and achieve linear time. No hashing/excessive space/ and don't use standard linear time deterministic selection algo| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 4of 8 votes
AnswersGiven a set top box:
- Guy January 18, 2014 in United States
a, b, c, d, e,
f, g, h, i, j,
k, l, m, n, o
p, q, r, s, t
u, v, w, x, y
z
Write code to give the character sequence given a word, For example, if the word is "CON", the function will print this:
Right//now we're at B
Right//now we're at C
OK//to select C
Down
DOwn
Right
Right
OK//to select O
Left//now at N
OK//to select N
note: Be careful when you're at Z. if you go to the right, you will get stuck.
Afterwards, the interviewer adds a space to the right of 'Z' to test the code.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 4of 8 votes
AnswersGiven a matrix with only 1s and 0s now find and PRINT SUB MATRIX WITH EQUAL NUMBER OF 0s AND 1s.
- codechamp March 29, 2014 in United States for Search| Report Duplicate | Flag | PURGE
A9 Software Engineer / Developer - 4of 6 votes
Answersgiven an int array with no duplicate numbers, write a function to return number of ways to calculate a target number.
- cooldog March 15, 2013 in United States
example: given {2,4,6,8} Target = 12
2 + 4 + 6 = 12,
4 + 8 = 12,
6 + 8 - 2 = 12,
2 - 4 + 6 + 8 = 12,
return 4| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Software Engineer in Test - 4of 6 votes
AnswersGive you two sequences of length N, how to find the max window of matching
- Code2Win June 08, 2013 in India
patterns. The patterns can be mutated.
For example, seq1 = “ABCDEFG”, seq2 = “DBCAPFG”, then the max window is 4. (
ABCD from seq1 and DBCA from seq2).| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer String Manipulation - 4of 6 votes
AnswersArrange the numbers in an array in alternating order.
- codefreak November 16, 2013 in United States
For example if the array is [a1, a2, a3, a4.. ]arrange the array such that b1<=b2>=b3<=b4 and so on.
Sampe Input: 3 5 7 8 4 9
Sample Output: 3 < 5 > 4 < 8 >7 < 9| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 4of 6 votes
AnswersGiven a server that has requests coming in. Design a data structure such that you can fetch the count of the number requests in the last second, minute and hour.
- AVK June 15, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures - 4of 4 votes
AnswersIf [a1,a2,a3...,an,b1,b2...bn] is given input change this to [a1,b1,a2,b2.....an,bn] , solution should be in-place
- Anonymous February 05, 2011| Report Duplicate | Flag | PURGE
Amazon Microsoft Developer Program Engineer Software Engineer / Developer Algorithm Arrays - 4of 4 votes
AnswersGiven a string S, you are allowed to convert it to a palindrome by adding 0 or more characters in front of it.
- xyz_coder November 20, 2014 in United States
Find the length of the shortest palindrome that you can create from S by applying the above transformation.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 4of 4 votes
AnswersGiven a large string T (up to 10M characters) and a large input stream of strings S(up to 1M strings), find for each Si in S if it is a subsequence of T.
- PrincessMaja November 17, 2013 in United States
String Si is a subsequence of T iff some letters from T can be omitted to obtain Si.
Example:
T - abbebcd
Si - bbcd
return true
T - abbeced
Si - bbbced
return false| Report Duplicate | Flag | PURGE
Software Engineer / Developer Algorithm - 4of 4 votes
AnswersGiven two (dictionary) words as Strings, determine if they are isomorphic. Two words are called isomorphic
- yashas.mavinkere November 07, 2013 in United States for Application
if the letters in one word can be remapped to get the second word. Remapping a letter means replacing all
occurrences of it with another letter while the ordering of the letters remains unchanged. No two letters
may map to the same letter, but a letter may map to itself.
Example:
given "foo", "app"; returns true
we can map 'f' -> 'a' and 'o' -> 'p'
given "bar", "foo"; returns false
we can't map both 'a' and 'r' to 'o'
given "turtle", "tletur"; returns true
we can map 't' -> 't', 'u' -> 'l', 'r' -> 'e', 'l' -> 'u', 'e' -'r'
given "ab", "ca"; returns true
we can map 'a' -> 'c', 'b'| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Data Structures - 4of 4 votes
AnswersGiven a array of size n. Divide the array in to two arrays of size n/2,n/2. such that average of two arrays is equal.
- gowthamganguri August 29, 2013 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 4of 4 votes
AnswersGiven an array A of N integers, we draw N discs in a 2D plane such that the I-th disc is centered on (0,I) and has a radius of A[I]. We say that the J-th disc and K-th disc intersect if J ≠ K and J-th and K-th discs have at least one common point.
- adam2008 February 22, 2013 in United States
Write a function:
int number_of_disc_intersections(int A[], int N);
that, given an array A describing N discs as explained above, returns the number of pairs of intersecting discs. For example, given N=6 and:
A[0] = 1 A[1] = 5 A[2] = 2
A[3] = 1 A[4] = 4 A[5] = 0
intersecting discs appear in eleven pairs of elements:
0 and 1,
0 and 2,
0 and 4,
1 and 2,
1 and 3,
1 and 4,
1 and 5,
2 and 3,
2 and 4,
3 and 4,
4 and 5.
so the function should return 11.
The function should return −1 if the number of intersecting pairs exceeds 10,000,000.
Assume that:
N is an integer within the range [0..10,000,000];
each element of array A is an integer within the range [0..2147483647].
Complexity:
expected worst-case time complexity is O(N*log(N));
expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).
Elements of input arrays can be modified.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 4of 4 votes
AnswersGiven an unordered array of positive integers, create an algorithm that makes sure no group of integers of size bigger than M have the same integers.
- Fred_Castro January 22, 2014 in United States
Input: 2,1,1,1,3,4,4,4,5 M = 2
Output: 2,1,1,3,1,4,4,5,4| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 4of 4 votes
AnswersPrint combinations of strings from List of List of String
- mohrmanla October 23, 2014 in United States
Example input: [[quick, slow], [brown, red], [fox, dog]]
Output:
quick brown fox
quick brown dog
quick red fox
quick red dog
slow brown fox
slow brown dog
slow red fox
slow red dog| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 4of 4 votes
AnswersGiven a polygon with N vertexes and N edges. There is an int number(could be negative) on every vertex and an operation in set(*,+) on every edge. Every time, we remove an edge E from the polygon, merge the two vertexes linked by the edge(V1,V2) to a new vertex with value: V1 op(E) V2. The last case would be two vertexes with two edges, the result is the bigger one.
- zilchistDeepblue January 15, 2013 in United States
Return the max result value can be gotten from a given polygon.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 4of 4 votes
AnswersGiven a current absolute path, e.g., "/usr/bin/mail", and a relative one, e.g, "../../../etc/xyz/../abc" return the absolute path created from the combination of the first two paths. In the example strings, the answer should be "/etc/abc".
- meh March 24, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm