Software Engineer / Developer Interview Questions
- 11of 11 votes
AnswersGive a N*N matrix, print it out diagonally.
- Mem February 28, 2014 in United States
Follow up, if it is a M*N matrix, how to print it out.
Example:
1 2 3
4 5 6
7 8 9
print:
1
2 4
3 5 7
6 8
9
This is the question in the phone interview.
Please share more questions.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 0 votes
AnswersProgram to check whether undirected graph is a tree or not?
- pavan February 27, 2014 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - 6of 8 votes
AnswersGiven a linked list where apart from the next pointer, every node also has a pointer named random which can point to any other node in the linked list. Make a copy of the linked list.
- Interviewee February 27, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 9of 9 votes
AnswersMicrosoft Excel numbers cells as 1...26 and after that AA, AB.... AAA, AAB...ZZZ and so on.
- Interviewee February 27, 2014 in United States
Given a number, convert it to that format and vice versa.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 1of 1 vote
AnswersDesign question: Say you have hacked in to a network and can deploy your bot thousands of machines, how would you design your bot so that all the machines work together to download a website, say wikipedia. There should be load balancing and a page should be queryable given its URL.
- Interviewee February 27, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 1of 1 vote
AnswersGiven a matrix of letters and a word, check if the word is present in the matrix. E,g., suppose matrix is:
- Interviewee February 27, 2014 in United States
a b c d e f
z n a b c f
f g f a b c
and given word is fnz, it is present. However, gng is not since you would be repeating g twice.
You can move in all the 8 directions around an element.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 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 - 1of 1 vote
AnswersGiven two arrays of sorted integers, merge them keeping in mind that there might be common elements in the arrays and that common elements must only appear once in the merged array.
- Interviewee February 27, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 0of 0 votes
AnswersDesign a musical jukebox using object-oriented principles
- .·´¯`·.´¯`·.¸¸.·´¯`·.¸><(((º> February 26, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - -6of 6 votes
AnswersModify the following code to add a row number for each line is printed
public class Test { public static void main(String [] args){ printParenthesis(3); } public static void printParenthesis(int n){ char buffer[] = new char[n*2]; printP(buffer,0,n,0,0); } public static void printP(char buffer[], int index, int n, int open, int close){ if(close == n){ System.out.println(new String(buffer)); }else{ if(open > close){ buffer[index] = ']'; printP(buffer, index+1, n, open, close+1); } if(open < n ){ buffer[index] = '['; printP(buffer,index+1,n,open+1,close); } } } }
Expected Output:
1.[][][] 2.[][[]] 3.[[]][] 4.[[][]] 5.[[[]]]
What changes needs to be done to accomplish the output expected?
- .·´¯`·.´¯`·.¸¸.·´¯`·.¸><(((º> February 25, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 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
AnswersGiven a normal binary tree, write a function to serialize it into a string representation (returning a string), and also a function to deserialize the string into the original binary tree
- Microwish February 25, 2014 in China| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 2 votes
AnswersFind the kth largest node in an unsorted linked list. ( Is quick select (selection algorithm) applicable on linked list (not array?)
- Guy February 25, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersSuppose you have a collection of collection
- MM February 24, 2014 in United States
Eg : CEO-> Vps-> GMs ->..
CEO will contain collection of VP's, VP's will have collection of GM's and so on.
Suppose you need to find a particular GM is the alias is given. Write a linq query to get the employee details if the employee alias is given.
Hint : Use Recursion + Linq| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Software Development Manager - -1of 3 votes
AnswersCheck if two binary search tree have the same in-order traversal in O(1) space
- Guy February 24, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven an array of integers and a length L, find a sub-array of length L such that the products of all integers are the biggest.
- hongbin034 February 24, 2014 in United States
Example:
Input: {4, 1, -7, -8, 9}, 3
Output: {-7,-8,9}| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswerQuestion 2) Implement insert and delete in a tri-nary tree. A tri-nary tree is much like a binary
- Pokiri February 24, 2014 in United States
tree but with three child nodes for each parent instead of two -- with the left node being values
less than the parent, the right node values greater than the parent, and the middle nodes values
equal to the parent.
For example, suppose I added the following nodes to the tree in this order: 5, 4, 9, 5, 7, 2, 2.
The resulting tree would look like this:
5
/ | \
4 5 9
/ /
2 7
|
2| Report Duplicate | Flag | PURGE
Software Engineer / Developer Algorithm - -3of 7 votes
AnswersFind a shortest path in a N*N matrix maze from (0,0) to (N,N), assume 1 is passable, 0 is not, 3 is destination, use memorization to cache the result. Here is my code. I am not sure if I am caching it right.
- Guy February 24, 2014 in United Statespublic static class MazeResult { public boolean solved; public List<String> res = new ArrayList<String>(); public int steps = Integer.MAX_VALUE; public MazeResult(boolean isSolved) { solved = isSolved; } } static Map<String, MazeResult> cache = new HashMap<String, MazeResult>(); static MazeResult solveMaze(int[][] m, int r, int c, List<String> path, HashSet<String> visited) { if (r < 0 || r >= m.length || c < 0 || c >= m[0].length) return new MazeResult(false); String cell = r + "" + c + ""; if (m[r][c]==0 || visited.contains(cell)) return new MazeResult(false); if (m[r][c] == 3) { MazeResult ret = new MazeResult(true); ret.res = new ArrayList<String>(path); ret.res.add(cell); ret.steps = path.size() + 1; return ret; } if (cache.containsKey(cell)) return cache.get(cell); path.add(cell); visited.add(cell); MazeResult ret = new MazeResult(false), temp = new MazeResult(false); temp = solveMaze(m, r, c+1, path, visited); compareResult(temp, ret); temp = solveMaze(m, r, c-1, path, visited); compareResult(temp, ret); temp = solveMaze(m, r+1, c, path, visited); compareResult(temp, ret); temp = solveMaze(m, r-1, c, path, visited); compareResult(temp, ret); path.remove(path.size()-1); visited.remove(cell); cache.put(cell, ret); return ret; } private static void compareResult(MazeResult temp, MazeResult ret) { if (temp.solved) { if (temp.steps < ret.steps) { ret.res = temp.res; ret.steps = temp.steps; } ret.solved = true; } }
| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - -3of 9 votes
AnswersFlatten an iterator of iterators in Java. If the input is [ [1,2], [3,[4,5]], 6], it should return [1,2,3,4,5,6]. Implement hasNext() and next().
- Guy February 24, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersSuppose you get number of unique users every second from bing
- MM February 24, 2014 in United States
For eg, 2,4,5,1,2,etc
You need to write a web service method , such that it takes the input n, which return lowest n unique number from the list of unique numbers. For eg, if n is 3 then you need to return 2,1,2| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 1of 1 vote
AnswersA draw method is given, write a function to draw a chess board. The Draw method, draws a square and has parameters row position, column position and color.
- MM February 23, 2014 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - -1of 3 votes
AnswersGiven a set of intervals, find the interval which has the maximum number of intersections (not the length of a particular intersection). So if input (1,6) (2,3) (4,11), (1,6) should be returned. Some suggest to use Interval Tree to get this done in O(logn), but I did not understand how to construct and use the Interval Tree after reading its wiki page. Is there any other way to do it? If Interval tree is the only option, please educate me how to construct/use one. Thanks.
- Guy February 23, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
Answers/**
- duskan February 22, 2014 in United States
* Returns a^b, as the standard mathematical exponentiation function
*/
public double pow(double a, int b) {}
Interviewer looking for log(n) solution, right on first attempt.| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Algorithm - 1of 1 vote
Answers/**
- duskan February 22, 2014 in United States
* Given a nested list of integers, returns the sum of all integers in the list weighted by their depth
* For example, given the list {{1,1},2,{1,1}} the function should return 10 (four 1's at depth 2, one 2 at depth 1)
* Given the list {1,{4,{6}}} the function should return 27 (one 1 at depth 1, one 4 at depth 2, one 6 at depth2)
*/
/**
* This is the interface that represents nested lists.
* You should not implement it, or speculate about its implementation.
*/
public interface NestedInteger
{
// Returns true if this NestedInteger holds a single integer, rather than a nested list
public boolean isInteger();
// Returns the single integer that this NestedInteger holds, if it holds a single integer
// Returns null if this NestedInteger holds a nested list
public Integer getInteger();
// Returns the nested list that this NestedInteger holds, if it holds a nested list
// Returns null if this NestedInteger holds a single integer
public List<NestedInteger> getList();
}| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Algorithm - 0of 2 votes
AnswerThey have given some flowchat questions in thought works ... how to solve these questions can anybody explain for all the questions....?
- premnath.velmurugan February 22, 2014 in India
http://placement.freshersworld.com/placement-papers/ThoughtWorks/Placement-Paper-Whole-Testpaper-29732| Report Duplicate | Flag | PURGE
Software Engineer / Developer Brain Teasers - 0of 0 votes
AnswersGiven a timer time() with nanosecond accuracy and given the interface
- / February 21, 2014 in United States
interface RealTimeCounter:
void increment()
int getCountInLastSecond()
int getCountInLastMinute()
int getCountInLastHour()
int getCountInLastDay()
implement the interface. The getCountInLastX functions should return the number of times increment was called in the last X.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven a list of pairs (a,b) where a is the number of a node and b is its parent, construct a tree and return the root.
- / February 21, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven a set of Lego bricks of height 1, 2, 3, and 4, each colored differently, write a program to compute the number of ways of constructing a tower of height n≥1.
- / February 21, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon 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 - 0of 0 votes
AnswersYou have two anagram strings S and P. You can do an operation swap(), which swaps two adjacent characters in a string, or swaps the last character and the first character in a string. What is the minimum number of operations you have to perform to change S to P.
- gyg February 21, 2014 in United States
E.g. S = "abcd", P = "bdca", the output should be 2, as "abcd" -> "dbca" -> "bdca".| Report Duplicate | Flag | PURGE
unknown Software Engineer / Developer Algorithm