Software Engineer Interview Questions
- 0of 0 votes
Answerscalculate minimum h-index for a sorted integer array(http://en.wikipedia.org/wiki/H-index)
- HBY April 17, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 1of 1 vote
AnswersAssuming you're playing one game that you need guess a word from a dictionary. You're given a machine you can try to guess the word, the machine will return how many characters has been matched by your guess. Design a system to crack the word.
- HBY April 17, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 1of 1 vote
AnswersPermutate a list of string
- HBY April 17, 2015 in United States
this question is supposed permutate the characters instead of who string,
as input example {"red", "fox", "super" }, the expected output is
rfs
rfu
rfp
rfe
rfr
ros
rou
rop
roe
ror
rxs
rxu
rxp
rxe
rxr
efs
efu
efp
efe
efr
eos
eou
eop
eoe
eor
exs
exu
exp
exe
exr
dfs
dfu
dfp
dfe
dfr
dos
dou
dop
doe
dor
dxs
dxu
dxp
dxe
dxr| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 1of 1 vote
AnswersA 2D array filled with integer, define a flow from one point to its neighbor only if the value of current point is not less than its neighbor's value. Consider up edge and left edge as east coast, bottom edge and right edge as west coast, find all position that it can flow to east coast and west cost both
- HBY April 17, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - -1of 1 vote
Answers/**
- dingdong April 16, 2015 in United States
* Find if the given list of recurring weekly intervals covers the
* entire time. Times are given up to a second.
*
* You can take the input intervals in the number of seconds since
* the beginning the week or any other format you prefer.
*
* ---Example 1---
* Input:
* Tuesday 9AM - Sunday 9AM
* Sunday 8:00:20AM - Wednesday 3AM
*
* Output:
* true
*
* ---Example 2---
* Input:
* Tuesday 9AM - Sunday 9AM
* Sunday 8:00:20PM - Tuesday 8AM
*
* Output:
* false
*/| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 3of 3 votes
Answers/*
- dingdong April 16, 2015 in United States
For each node in a binary tree find the next right node on the same depth. Write a function that takes root node and populates "next" with the answer for each node.
A
/ \
B -> C
/ / \
D -> F-> G
/ \
H -> I
class Node {
Node left;
Node right;
Node next; // <-- answer should be stored here
};
B.next = C
D.next = F
F.next = G
H.next = I
{A, C, G, I}.next = null
*/| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - -4of 4 votes
AnswersPangram
- Kiara April 16, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 0of 2 votes
AnswersIn-place Palindrome Check
- Kiara April 16, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer - -5of 7 votes
Answersdutch national flag w/ get rank followup
- Kiara April 16, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 0of 0 votes
AnswersYou are given a system call
system.schedule(Runnable task, int seconds)
The function can handle only one invocation; for example, if called
system.schedule(task1, 3); system.schedule(task2, 6); system.schedule(task3, 9);
the first and second calls will be "forgotten". Only the third one will be scheduled.
- feqs April 15, 2015 in United States
Implement a class MyTimer with method mySchedule(Runnable, int) that can handle unbounded number of calls without forgetting. Use the system.schedule() function.| Report Duplicate | Flag | PURGE
Software Engineer Java - 0of 0 votes
AnswersWrite a function
- psuedo April 10, 2015 in India
bool fancy_shuffle(char* s);
which rearranges characters in the string given as input, in such a way that no same character occurs twice in a row (that is, next to each other).
If such rearrangement is not possible, the function should return false.| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 1of 1 vote
AnswersGiven an array of numbers, find a pair whose sum is closest to zero.
- psuedo April 10, 2015 in India| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersYou are given a log of wood of length `n’. There are `m’ markings on the log. The log must be cut at each of the marking. The cost of cutting is equal to the length of the log that is being cut. Given such a log, determine the least cost of cutting.
- psuedo April 10, 2015 in India| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 3of 3 votes
AnswersN queen problem.
- animageofmine April 08, 2015 in United States
In NXN chess board, you have to arrange N queens such that they do not interfere each other. Following is how you define interference of queens.
1. Two queens cannot be on the same diagonal
2. Two queens cannot be in same horizontal or vertical line
3. Queen can jump like a knight. So, two queens cannot be at a position where they can jump two and half steps like a knight and reach the other queen.
You should return the possible ways to arrange N queens on a chess board.
This was a tech screen, but since I was local, they called me in their office rather than phone interview.
Hint: Don't try too hard, the best solution is n!| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 1of 1 vote
Answerswrite custom pattern match function to match following logic
.’ Matches any single character.
‘*’ Matches zero or more of the preceding element.
The matching should cover the entire input string (not partial).
The function prototype should be:
- storb99 April 07, 2015 in United Statesbool isMatch(const char *s, const char *p) Some examples: isMatch(“aa”,”a”) → false isMatch(“aa”,”aa”) → true isMatch(“aaa”,”aa”) → false isMatch(“aa”, “a*”) → true isMatch(“aa”, “.*”) → true isMatch(“ab”, “.*”) → true isMatch(“aab”, “c*a*b”) → true isMatch(“ccca”, “c*a”) → true
| Report Duplicate | Flag | PURGE
Yahoo Software Engineer Coding - 0of 0 votes
AnswersGiven an array of ints, return a string identifying the range of numbers
- tbag March 31, 2015 in United States
Example
Input arr - [0 1 2 7 21 22 1098 1099]
Output - "0-2,7,21-22,1098-1099"| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 0of 0 votes
AnswersGiven N co-ordinates on a 2D plane, find two co-ordinates such that their slope is maximum. An efficient solution was asked.
- GAURAV March 31, 2015 in India| Report Duplicate | Flag | PURGE
Coupon Dunia Software Engineer Algorithm - 0of 0 votes
AnswersFind minimum number of swaps to convert one binary array to another.
- Rahul Sharma March 30, 2015 in United States
Note: It is always possible.
You are given two integer array having only 0's and 1's. Find minimum number of swaps to convert array1 to array2.
NOTE: You can only swap adjacent elements.| Report Duplicate | Flag | PURGE
Adobe Software Engineer Algorithm - -2of 4 votes
Answerspublic class MyClass {
- MrA March 29, 2015 in United States
public static int num=1;
public static boolean flag=false;
public static void main(String[] args) {
Thread t =new Thread(new MyThread());
t.start();
MyClass.flag=true;
MyClass.num=10;
}
}
class MyThread implements Runnable{
public void run() {
while(!MyClass.flag){
Thread.yield();
}
System.out.println(MyClass.num);
}
}
Output of this code and the reason for the output?| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer Java - 0of 2 votes
AnswersDesign an optimised algorithm to solve snakes and ladders with the least amount of roles possible under the assumption that you get whatever role you want when you role the dice.
- abc March 26, 2015 in United Kingdom for Graduate| Report Duplicate | Flag | PURGE
Google Software Engineer Dynamic Programming - 0of 0 votes
AnswersThis is a two part question related to Markov string generation.
- Lively March 25, 2015 in United States
Part 1: Read a training set of strings. For each character in any of the strings, calculate the probability of seeing that character and store it for later use. (this part is about coming up with the right data structure and correct probability calculation).
Part 2: Based on the training set from Part 1, generate a random string of length N.| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
AnswersGiven an API ReadFromDisk() which returns a block of 256 bytes from disk. Implement the API Read(SizeInBytes) which reads SizeInBytes bytes from the disk by calling only ReadFromDisk. Notice that every call to ReadFromDisk() will read the next 256 bytes from disk.
- Lively March 25, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersGiven an API ReadFromDisk() which returns a block of 256 bytes from disk. Implement the API ReadEx(SizeInBytes) which reads SizeInBytes bytes from the disk by calling only ReadFromDisk. Notice that every call to ReadFromDisk() will read the next 256 bytes from disk.
- Lively March 25, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 2 votes
Answerswrite a function that calculates the minimum number of meeting rooms that can accommodate given schedules
- bazinga March 24, 2015 in United States
input: same
output: # of rooms
Also back to back events are allowed e.g. {2,5} {5,9} correct o/p:1| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 2of 2 votes
Answerswrite a function that detects conflicts in given meeting schedules
- bazinga March 24, 2015 in United States
input: a list of intervals, [(s1, e1), (s2, e2), ]
output: return True if there's any conflict, False otherwise| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 0 votes
AnswerThe last one, he gave me one single line : " amazon is a . blah blah blah.." then he told me to compress it.
- darpanshah08 March 24, 2015 in United States for Amazon Prime
I used the indexes,occurences. But then he told me to use other way. after he gave me some hint, I was able to find out the palindrome pattern. we can use that too to compress the string.
Then he told me to write algorithm for palindrome, I wrote with O(n/2) complexity. then he told me to find any longest palindrome from the string. I need to use my palindrome algorithm too.
I tried a lot and then I came up with O(n^3) solutions. he pushed me to try to reduce with O(n^2) solution. However, I could not come up with that solution.| Report Duplicate | Flag | PURGE
US Software Engineer - 0of 0 votes
AnswersBased on the above question, he asked me that I have a very large file with all the details of product, like id, name, qty_sold, date. then he told me to find out the products that will have a better chances to be sold out next week. I have to find out the products that will sell more in next week.
- darpanshah08 March 24, 2015 in United States for Amazon Prime| Report Duplicate | Flag | PURGE
US Software Engineer - 0of 0 votes
AnswersSecond round was intersting: that guy gave me a situation, like I have a file with columns product_id, qty, date, product_name.
- darpanshah08 March 24, 2015 in United States for Amazon Prime
I need to sort them based on qty that has been sold out on day. For example, this product has been sold highest on this day.| Report Duplicate | Flag | PURGE
US Software Engineer Algorithm Hash Table - 0of 0 votes
AnswersIn my First round, very first question that guy asked me is to generate an algorithm to check whether string is palindrome or not. After that in the same round, he asked me to create a class that duplicates the Stack property.
First, String Palindrome:
Used stringbuilder, i.e.StringBuilder sb = new StringBuilder(str); System.out.println(sb.reverse());
then he told me to not to use StringBuilder, so i convert string into the char array, then apply loop till half the size of the string. and check character by character. He said ok. "looks good".
- darpanshah08 March 24, 2015 in United States for Amazon Prime| Report Duplicate | Flag | PURGE
US Software Engineer Stacks String Manipulation - 2of 2 votes
AnswersYou are given printouts from an algorithm which ran over an unsorted binary tree. One printout is from an in-order run and another from a pre-order run. Can you reconstruct the tree? If so, then write an algorithm.
- tested.candidate March 22, 2015 in UK| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm