Software Engineer / Developer Interview Questions
- 3of 3 votes
Answers# take an array and print non over lapping in order pairs. example:
- thegeek21 June 05, 2016 in United States# [1,2,3,4] => input # output below is in order combination # (1234) # (1)(234) # (1)(23)(4) # (1)(2)(34) # (12)(34) # (12)(3)(4) # (123)(4) # (1)(2)(3)(4)
| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 3of 3 votes
AnswersRound 3 :
- sonesh January 03, 2013 in India
Q 5 : You are given a binary search tree, and a value(data item), you need to tell the left most right cousin in as minimum time and as minimum space ?(need to minimize actual time complexity, he need minimum order of complexity as well as number of node access should be minimum)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Data Structures Trees and Graphs - 3of 3 votes
AnswersWrite a program to find pattern.
- pritishshah.it November 20, 2014 in United States
0: 1
1: 11
2: 21
3: 1211
4: 111221
5: 312211
Iterate over the previous number, and find count for same number number. Append that count before number.
e.g.,
public String pattern(int input){}
If input = 4, function should return 111221.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 3of 3 votes
AnswersGiven n light bulbs, write two methods.
- cup August 19, 2015 in United States
isOn(i) to determine if a light bulb is on
toggle(start, end) to toggle all the light bulbs in the range
One caveat, write toggle so that it is less than O(n) complexity| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 3of 3 votes
AnswersCode for computing a^b and optimize it.
- AlgoAlgae April 25, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 3of 3 votes
AnswersHow do you remove repeated values from a INT array, returning the resultant array in the same order as original ?
- Mauricio.Malf February 20, 2013 in Netherlands| Report Duplicate | Flag | PURGE
Booking.com Software Engineer / Developer Algorithm - 3of 3 votes
AnswersCode a function that gets two strings representing binary numbers (so the only possible characters are '1' and '0', and returns a third string representing the sum of the input. The input strings don't necessarily have of the same length.
- diegum June 06, 2014 in United States for iOS
Tell the complexity of the solution.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer String Manipulation - 3of 3 votes
AnswersTwo sorted array. Find kth smallest element
- pkn May 19, 2012 in India
O(logK)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 3of 3 votes
AnswersLet's assume that there's an array that has nonzero natural numbers where all the numbers repeat an even number of times, except for one value that repeats an odd number of times. Can you write me a function that takes this array, and returns the value that occurs the odd number of times?
- danny April 17, 2015 in United States for Amazon Music
Ex : - [ 4, 7, 2, 2, 5, 3, 5, 7, 7, 3, 4, 5 ]| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 3of 3 votes
AnswersFind a given element in sorted array.
- tazo February 10, 2015 in United States
arr= [1, 2, 3, 4, 5, 6]
follow up: If the sorted array is shifted left by unknown number, modify existing binary search to find a element in modified array
arr = [4, 5, 6, 1, 2, 3]| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Arrays - 3of 3 votes
AnswersThere is rotated sorted array.Write the program to find any element in that array
- akash.patel06@sjsu.edu February 22, 2013 in United States
Original Array A={1,2,3,5,6,7,8}
Rotated Array B={5,6,7,8,1,2,3}
Write the program to find any element in array B| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Algorithm - 3of 3 votes
AnswersHow many occurrences of a given search word can you find in a two-dimensional array of characters given that the word can go up, down, left, right, and around 90 degree bends?
- lueikhong June 07, 2014 in Australia
Ex:
Count of occurrences of SNAKES
S N B S N
B A K E A
B K B B K
S E B S E
The answer is 3.
Write a program for that question.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 3of 3 votes
Answerswe have a random list of people. each person knows his own height and the number of tall people in front of him. write a code to make the equivalent queue.
- pari February 18, 2014 in United States
for example :
input: <"Height","NumberOfTall","Name">,
<6,2,"A">,<1,4,"B">,<11,0,"C">,<5,1,"D">,<10,0,"E">,<4,0,"F">
output: "F","E","D","C","B","A" --> end of queue| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 3of 3 votes
AnswersCoding:
Public void TransferAccount(AccountID id1, AccountID id2){ Account a1 = id1.GetAccount(); Account a2 = id2.GetAccount(); //Swap amounts. Temp = a1.Balance; a1.Balance = a2.Balance; a2.Balance = Temp; }
Q1: How do you make it thread safe?
I said use “public void synchronized” Good. But terrible performance since the entire method is synchronized.
Q2: Can you not lock on the entire method? I said used nested locks:Synchonized(a1) Synchronized(a2) { //swap }
His q: This will lead to a deadlock if in another thread I call Transfer (id2, id1) and Transfer (id1, id2).
Synchonized(a1) Synchronized(a2) { //swap }
Synchonized(a2) Synchronized(a1) { //swap }
How do you prevent this then? How do you design your code to not to get in to deadlock? (stumbled here)
- xankar March 16, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Java Threads - 3of 3 votes
AnswersPrint all possible palindromes(of length >2) for a given string.
- Anonymous January 24, 2011| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 3of 3 votes
AnswersImplement a stack with O(1) push, pop, and min
- msito October 14, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Stacks - 3of 3 votes
AnswersRotate a array by N. N can be smaller of greater than the array length.
- someone June 10, 2015 in United States
e.g {0,1,2,4,5,6,7} N =4 should return {5,6,7,4,0,1,2}.
1) I did this using extra array but next I was asked to do without extra array and in o(n) time.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 3of 3 votes
AnswersYou are given an array of distinct numbers. You need to return an index to a "local minimum" element, which is defined as an element that is smaller than both its adjacent elements. In the case of the array edges, the condition is reduced to one adjacent element.
- Anonymous January 27, 2015 in Israel
Reach a solution with better time complexity than the trivial solution of O(n).
If there are multiple "local minimums", returning any one of them is fine.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 3of 3 votes
AnswersGive the algorithm and code to get the depth of the deepest odd level leaf node in a binary tree.
- tom March 04, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures - 3of 3 votes
Answerswrite a function:
int median(int a, int b, int c)
and then write another function:
- ghirlwhocodes April 23, 2015 in Switzerlandint median(int a, int b, int c, int min, int max)
| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 3of 3 votes
AnswersFind the longest words in a given list of words that can be constructed from a given list of letters.
- Rohitraman2006 August 01, 2014 in United States
Your solution should take as its first argument the name of a plain text file that contains one word per line.
The remaining arguments define the list of legal letters. A letter may not appear in any single word more times than it appears in the list of letters (e.g., the input letters ‘a a b c k’ can make ‘back’ and ‘cab’ but not ‘abba’).
Here's an example of how it should work:
prompt> word-maker WORD.LST w g d a s x z c y t e i o b
['azotised', 'bawdiest', 'dystocia', 'geotaxis', 'iceboats', 'oxidates', 'oxyacids', 'sweatbox', 'tideways']
Tip: Just return the longest words which match, not all.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 3of 3 votes
AnswersGiven a string, you need to find super string by word match. i.e. all words in the input string has to occure in any order in output string.
- zc51 March 29, 2013 in India
e.g. given data set:
"string search"
"java string search"
"manual c++ string search equals"
"java search code"
"c++ java code search"
...
input: "java search"
output:
1) "java string search"
2) "java search code"
3) "c++ java code search"
input: "c++ search"
output:
1) "manual c++ string search equals"
2) "c++ java code search"
There are millions of records in given data set and you need to process few million as input.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Data Mining - 3of 3 votes
AnswersGiven two parameters (a target string and a source string), write code that returns the number of times characters found in the source string occur in the target string.
- ootah November 14, 2013 in United States
For example, if target="Hello world" and source="llld" then return 4| Report Duplicate | Flag | PURGE
Citrix System Inc Software Engineer / Developer C - 3of 3 votes
AnswersLet's say there is a double square number X, which can be expressed as the sum of two perfect squares, for example, 10 is double square because 10 = 3^2 + 1^2
- baudday November 17, 2014 in United States for Emerging Markets
Determine the number of ways which it can be written as the sum of two squares| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 3of 3 votes
AnswersWrite an algorithm to find the ‘next’ node (e.g., post-order successor) of a given node in a binary tree and binary search tree
- Jeff May 18, 2014 in United States
a.) where each node has a link to its parent.
b.) without parent pointer
implement 2 versions of the algorithm: 1.) binary tree 2.) BST| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 3of 3 votes
AnswersReturn a shortest prefix of <code>word</code> that is <em>not</em> a prefix of any word in the <code>list</code>
- pk March 07, 2013 in United States
e.g.
word: cat, it has 4 prefixes: “”, “c”, “ca”, “cat”
list: alpha, beta, cotton, delta, camera
Result is “cat”| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 3of 3 votes
AnswersAs kernel can access user space memory, why should copy_from_user is needed?
- bvgr December 24, 2012 in United States| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer / Developer Linux Kernel - 3of 3 votes
AnswersAssume there are 10000 stars in sky, how would you find which star is closest to the earth? in C
- The Puzzler 2.0 January 05, 2016 in India| Report Duplicate | Flag | PURGE
Software Engineer / Developer C - 3of 3 votes
Answerspublic class LogEntry {
- Invhelper May 05, 2014 in United States
public final long startTime; // start time of a job in millisec granularity
public final long endTime; // end time of a job in millisec granularity.
public final long ram; // the amount of ram the job occupies.
public final long jobId;
... constructor ...
}
running total of RAM
|
| 3GB
| -----
| 2GB
| ------
| 1GB -----------
|----- -----------
|
|____________________________________________________time
Find the peakRAM when the input is a collection of LogEntry objects| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding