Software Engineer / Developer Interview Questions
- 2of 2 votes
AnswersWrite an application in Java to simulate file system. For e.g. implement commands: ls -l (list contents of director sorted by name), cd .. (to go to parent directory), pwd to return the complete path to current directory etc. It was a 2 hour remote programming test.
- techpanja February 13, 2014 in United States
Your system will have Directory and Files. A directory can contain files and other directories.| Report Duplicate | Flag | PURGE
Salesforce Software Engineer / Developer - 2of 2 votes
AnswersYou are given N blocks of height 1…N. In how many ways can you arrange these blocks in a row such that when viewed from left you see only L blocks (rest are hidden by taller blocks) and when seen from right you see only R blocks? Example given N=3, L=2, R=1 there is only one arrangement {2, 1, 3} while for N=3, L=2, R=2 there are two ways {1, 3, 2} and {2, 3, 1}.
- game January 21, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersThere is a circular train (the head is connected to the tail) where each car of the train contains a light bulb. Initially, the bulbs are randomly switched on/off.
- pavel.em November 04, 2015 in Germany
You need to determine the size of the train (the number of cars)
by going from one car to another and switching the light bulbs| Report Duplicate | Flag | PURGE
Yandex Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven an array of type:-
- anupjunagadecat November 25, 2014 in India for 11
1. Increasing
2. Decreasing.
3. Increase-Decrease
4. Decrease-Increase
Find:- 1. Type of array in minimum steps ?
2. Maximum element from array in min steps?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
AnswersWhen a person who knows it meets any other person, they immediately share the story with them.
- veeru June 25, 2021 in India
Initially, only person 1 knows the story. Given a list of meetings between people in a form of
(person_1_id, person_2_id, timestamp) construct a list of the persons who will know the story
at the very end.
Example: [(1, 2, 100), (3,4, 200), (1,3, 300), (2,5, 400)], 1 // The events could be out of order.
Person 2 will learn the story at the moment 100, person 3 — at the moment 300,
person 5 — in the moment 400. Person 4 will never learn the story. So the answer is [1, 2, 3, 5].
Eg2: [(1, 2, 100), (2, 3, 100), (4, 5, 100)], 2
where the first parameter is array of the Persons meet at particular timestamp, second parameter is the PersonId who knows the story first.
Output: [1, 2, 3]| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures - 2of 2 votes
AnswersGiven a normal binary tree, write a function to serialize the tree into a string representation (returning the string), and also a function to deserialize a serialized string into the original binary tree.
- Microwish February 25, 2014 in China| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 2of 2 votes
Answers'K' number of char arrays of different length are given, find Cartesian product of them in optimal way & give complexity. I used divide & conquer.
- ameyabap February 23, 2013 in India for AppeX| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 2of 2 votes
AnswersYou are trying to control an on-screen keyboard (e.g. on a television) that looks like this:
- msamarch1980 March 20, 2014 in United States
a b c d e
f g h i j
...
You can issue the following commands to move the cursor and select letters:
‘u’ - up
‘d’ - down
‘l’ - left
‘r’ - right
‘!’ - select letter
You are given an input string and the length of the rows in the on-screen keyboard. You must produce the sequence of commands needed to type out the input string on the specified keyboard, e.g.:
“aci”, 5 -> “!rr!dr!”| Report Duplicate | Flag | PURGE
Software Engineer / Developer Coding - 2of 2 votes
AnswersGiven a matrix consisting of 0's and 1's, find the largest connected component consisting of 1's.
- Interviewee February 27, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 2of 2 votes
AnswersFind the max height of a binary tree.
- techpanja October 22, 2013 in United States for yammer| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 2of 2 votes
AnswersArrange 1 to N in random order with no duplication.
- codomania March 07, 2013 in United States for Windows Phone| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 2of 2 votes
AnswersCan you predict the output of the following code?
- Prithvi October 06, 2013 in Nepal for Java Developerfor (int i = 0; i < 101; i++) { if (i % 2 == 0) { System.err.print(i); } else System.out.print(i); }
| Report Duplicate | Flag | PURGE
Software Engineer / Developer Java - 2of 2 votes
AnswersGiven a function getRandom that returns a random double in [0,1). Write a function getRandomPermutation(int n) that takes a positive integer n as argument and returns a random permutation of first n natural numbers.
- AlgoBaba November 15, 2016 in India| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersWhat is the fastest way to compute cube root?
- Ray November 14, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven an input list of lists.. flatten the list. For e.g.
- techpanja October 22, 2013 in United States for yammer
{{1,2}, {3}, {4,5}} ... Output should be {1, 2, 3, 4, 5}| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 2of 2 votes
AnswersSelect a random node data from a very long linked list whose length is not known such that the probability of each node is equal.
- ishwant.nandra January 17, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Linked Lists - 2of 2 votes
AnswersShuffle a given array such that each position is equally likely.
- xmlprgrm June 15, 2015 in United States| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Algorithm - 2of 2 votes
AnswersDesign a vending machine
- JSDUDE October 27, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Object Oriented Design - 2of 2 votes
AnswersDesign a parking lot system where you need to provide a token with the parking space number on it to each new entry for the space closest to the entrance.
- duskan February 13, 2014 in United States for Sales
When someone leave you need update this space as empty.
What data structures will you use to perform the closest empty space tracking, plus finding what all spaces are occupied at a give time.| Report Duplicate | Flag | PURGE
Apple Software Engineer / Developer Algorithm - 2of 2 votes
AnswersI was asked a question in an interview.
- Park February 06, 2014 in India
On an office floor , there are e entities - Walls , Cubicles , Coffee Rooms.
In what data structure we should store this design that when a new member joins the company , the cubicle number which is empty and next closest to any coffee room should be assigned to it.
Basically , data structure DS.pop() should return that cubicle number in the most efficient way.
A Person can walk through cubicles to reach a coffee room but not through walls.| Report Duplicate | Flag | PURGE
Motorola Software Engineer / Developer Data Structures - 2of 2 votes
AnswersGiven a matrix M with (with positive or negative numbers) find the largest sum S of any sub-matrix of M.
- Omar.Enayet November 02, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 2of 2 votes
AnswersDesign the Facebook newsfeed for an Android app. The actual design would be very complex so you may limit your solution to only status updates and photo posts. Keep your answer broad rather than deep since it would need to fit in a 45-minute interview.
- Barry Fruitman March 20, 2013 in United States
Normally you would need to ask the interviewer a lot of questions but since that is not possible here, state your assumptions.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Android - 2of 2 votes
AnswersGiven a linked list: 5 -> 4 -> 3 -> 2 -> 1, produce the following output: 4 -> 2 -> 0 -> 2 -> 1 by substracting the 1st node with nth node, the 2nd with nth -1 node, etc... Only apply the stated action on the first half of the list
- NL May 11, 2014 in United States| Report Duplicate | Flag | PURGE
Software Engineer / Developer Coding - 2of 2 votes
AnswersWhat is the difference between a computers heap and it's stack?
- brighama March 29, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Computer Architecture & Low Level - 2of 2 votes
AnswersDesign an HTTP downloader that caches results and doesn't block execution (i.e., enables simultaneous downloads).
- diegum June 06, 2014 in United States for iOS| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Object Oriented Design - 2of 2 votes
AnswersDesign an iterator for a given stream of integers, with next() and hasnext() being called in any sequence, but skipping any 0's in the stream.
- duskan March 20, 2014 in United States for Ad| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Algorithm - 2of 2 votes
AnswersCreate a data structure that has fast insertion, removal, membership testing, and random selection.
- / February 21, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
AnswersDesign the backend for a Gmail-like mail system
- Steve September 14, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Application / UI Design - 2of 2 votes
AnswersDoes it always happen that stack always grows downwards & heap grows upwards?
- Aashish June 22, 2012 in India
If its so, then how does OS keeps the heap area protected from the interference of the stack & vice-versa?
If its not, then what factors affect it? OS version ? Compiler? Anything else??| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Operating System