Software Engineer Interview Questions
- 0of 0 votes
AnswersOn a table there are four papers, one with the letter X written on top, one with the letter Y written on top, one with the number 1 written on top, and one with the number 2 written on top. Every paper has one of those letters on one side and one of those numbers on the other side. To prove that a paper with the letter x contains even number on the other side, what is the minimum number of conditions we have to check?
- LeetJile February 23, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Brain Teasers - 0of 0 votes
AnswersHow would you get all of the unique IDs out of a single file? What if it was a very large file?
- LeetJile February 23, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Knowledge Based - 1of 1 vote
AnswersConvert a binary tree into a In Order traversal circular list re-purposing the node's pointers Left & Right as Previous and Next respectively.
- Nelson Perez February 22, 2015 in United States
Hint: A single node Left & Right points to itself.
Note: This is not a binary search tree.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Coding - 0of 0 votes
Answers2. CURIOUS ANT (easier)
- Sritharan Mahendra Babu February 22, 2015 in United States
Assume you have a typical tree-like structure. Each branch can have more children branches but it can also have some number of fruits (this is just a number associated with each branch).
Imagine an ant that wants to start at the root or the tree and go to the very end of some branch path. The ant is asking you: is it possible for me to encounter at least N fruits on my way?
Write a program that answers Yes or No to this question.
Write the code in Python| Report Duplicate | Flag | PURGE
Pixability Software Engineer Algorithm - -1of 1 vote
Answers1. DR. ROPES (harder)
- Sritharan Mahendra Babu February 22, 2015 in United States
Assume you have some number of ropes of varying length.
For example: 2 ft, 5 ft, 6 ft, 6 ft (possible to have two or more ropes of the same length).
Write a program that determines if it is possible to string together the ropes to produce length of exactly N.
For the example set above, your program would answer:
N of 7 : yes
N of 11 : yes
N of 3 : no
N of 12 : yes
N of 18 : no
Note: Please write your solution without using the itertools package.
Write the code in Python| Report Duplicate | Flag | PURGE
Pixability Software Engineer Algorithm - 0of 0 votes
AnswersWrite a function that takes an array of numbers and returns the maximum and minimum values.
- trophygeek February 21, 2015 in United States
Give BigO for runtime.
(This is a basic coding question. There are no real tricks or shortcuts.)| Report Duplicate | Flag | PURGE
Google Software Engineer Coding - 1of 1 vote
AnswersSingleton(write a singleton class , and when we use singleton ) , design pattern , serialize , implement with existing code : Comparable(compareTo()) , hashCode() , equals , synchronize . what is SWING ? , what is WebStart ?
- pointer.ptr February 20, 2015 in United States for Java| Report Duplicate | Flag | PURGE
Amdocs Software Engineer - 0of 0 votes
Answer* input :
- pointer.ptr February 20, 2015 in United States for Java
point (x,y) - assume that the point exist into the shape
isBounded(x,y) : return 1 if the point (x,y) is out of shape , and return 0 if the point (x,y) is into shape
task : to write a code\pseudo code to print a shape with input| Report Duplicate | Flag | PURGE
Amdocs Software Engineer - 0of 0 votes
AnswersGiven a string and a dictionary, return an array of all the possible ways the string can be broken into different valid words.
i.e. Given `hotelfeat` return [ ["hot", "elf", "eat"], ["hotel","feat"] ]
For the dictionary you can assume that you either have a large set of valid words or you can call something like
public Boolean isValidWord(String str)
The method signature would look something like the following in Java:
public ArrayList<ArrayList<String>> possibleWordCombinations(String str, Dictionary dict);
A correct answer would use recursion and/or dynamic programming.
- Sydney February 19, 2015 in United States| Report Duplicate | Flag | PURGE
Software Engineer Algorithm - 1of 1 vote
AnswersGiven an array of n integers, return the maximum PMEAN of all possible array rotations, where PMEAN = the sum of each integer multiplied by its current location (index + 1). For example: The PMEANs for every rotation of the array {20, 30, 10} are: PMEAN1 = (1 * 20) + (2 * 30) + (3 * 10) = 110 PMEAN2 = (1 * 30) + (2 * 10) + (3 * 20) = 110 PMEAN3 = (1 * 10) + (2 * 20) + (3 * 30) = 140 The max PMEAN of array {20, 30, 10} is 140.
The question is simple enough. I was able to get a working algorithm quick enough, but I failed to optimize my answer.
- Sydney February 19, 2015 in United States
Hint from the interviewer:
If you have PMEANn, how can you use the result to get PMEANn+1?| Report Duplicate | Flag | PURGE
Yahoo Software Engineer - 0of 0 votes
AnswersFind the first word in a stream in which it is not repeated in the rest of the stream. Please note that you are being provided a stream as a source for the characters. The stream is guaranteed to eventually terminate (i.e. return false from a call to the hasNext() method), though it could be very long. You will access this stream through the provided interface methods. A call to hasNext() will return whether the stream contains any more characters to process. A call to getNext() will return the next character to be processed in the stream. It is not possible to restart the stream.
- anca.grigoras88 February 16, 2015 in United States
Example:
Input: The angry dog was red. And the cat was also angry.
Output: dog
In this example, the word ‘dog’ is the first word in the stream in which it is not repeated in the stream.| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 0of 0 votes
AnswersWrite a utility function that takes the starting position (P0) and length (L0) of one line segment plus the start position (P1) and length (L1) of a second line segment and returns the configurations where both segments end at the same point. Both starting points can be anywhere in three dimensional space.
- GameDev33 February 09, 2015 in United States| Report Duplicate | Flag | PURGE
Software Engineer Algorithm C++ Math & Computation Matrix - 0of 0 votes
AnswerThe problem is to write a set of functions to manage a variable number of byte queues, each with variable length, in a small, fixed amount of memory.
You should provide implementations of the following four functions:
// Creates a FIFO byte queue, returning a handle to it.
Q * create_queue();
// Destroy an earlier created byte queue.
void destroy_queue(Q * q);
// Adds a new byte to a queue.
void enqueue_byte(Q * q, unsigned char b);
// Pops the next byte off the FIFO queue
unsigned char dequeue_byte(Q * q);
So, the output from the following set of calls:Q * q0 = create_queue(); enqueue_byte(q0, 0); enqueue_byte(q0, 1); Q * q1 = create_queue(); enqueue_byte(q1, 3); enqueue_byte(q0, 2); enqueue_byte(q1, 4); printf("%d", dequeue_byte(q0)); printf("%d\n", dequeue_byte(q0)); enqueue_byte(q0, 5); enqueue_byte(q1, 6); printf("%d", dequeue_byte(q0)); printf("%d\n", dequeue_byte(q0)); destroy_queue(q0); printf("%d", dequeue_byte(q1)); printf("%d", dequeue_byte(q1)); printf("%d\n", dequeue_byte(q1)); destroy_queue(q1);
should be:
- GameDev33 February 09, 2015 in United States
0 1
2 5
3 4 6
You can define the type Q to be whatever you want.
Your code is not allowed to call malloc() or other heap management routines. Instead, all storage (other than local variables in your functions) must be within a provided array:
unsigned char data[2048];
Memory efficiency is important. On average while your system is running, there will be about 15 queues with an average of 80 or so bytes in each queue. Your functions may be asked to create a larger number of queues with less bytes in each. Your functions may be asked to create a smaller number of queues with more bytes in each.
Execution speed is important. Worst-case performance when adding and removing bytes is more important than average-case performance.
If you are unable to satisfy a request due to lack of memory, your code should call a provided failure function, which will not return:
void on_out_of_memory();
If the caller makes an illegal request, like attempting to dequeue a byte from an empty queue, your code should call a provided failure function, which will not return:
void on_illegal_operation();
There may be spikes in the number of queues allocated, or in the size of an individual queue. Your code should not assume a maximum number of bytes in a queue (other than that imposed by the total amount of memory available, of course!)
You can assume that no more than 64 queues will be created at once.| Report Duplicate | Flag | PURGE
Software Engineer C C++ - 0of 0 votes
AnswersA new airline company is setting up operations and needs your help! They want to optimize their routes so as to cover a full list of cities, wile minimizing the cost of their operations.
- twinmind February 04, 2015 in United Kingdom
You are provided with the number of N cities and with the costs of operating flights between some of the cities.
Can you design an algorithm that will return the list of routes that cover all the N cities at the minimum operational cost?
Assumtions:
1. not all direct routes between cities are possible, but all cities can be reached either directly of via intermediate cities. You are provided with the complete set of routes that are possible as input to your algorithm.
2. the costs of operating a route from any city to any other directly connected city is known and unique (i.e., no two costs between direct routes are the same)
3. the cost of operating a route from city X to city Y is equal to the cost of operating the route from city Y to city X
Your algorithm will get as input from stdin the following:
1. on the first line, the number of cities N
2. on the second line, the total number of possible routes K
3. on the subsequent K lines, the possible routes between cities and their operational cost, separated by spaces. Cities are integer numbers from 0 to N-1. costs are floats.
The output of your algorithm should be the list of routes chosen to be operated at the minimum cost, one route per line. After the list of routes, on the final line the total cost of operating all chosen routes should be printed.
What is the time complexity of the algorithm you've created?
Example:
Input
8
16
4 5 0.35
4 7 0.37
5 7 0.28
0 7 0.16
1 5 0.32
0 4 0.38
2 3 0.17
1 7 0.19
0 2 0.26
1 2 0.36
1 3 0.29
2 7 0.34
6 2 0.40
3 6 0.52
6 0 0.58
6 4 0.93
Output
0 7 0.16
2 3 0.17
1 7 0.19
0 2 0.26
5 7 0.28
4 5 0.35
6 2 0.40
1.81| Report Duplicate | Flag | PURGE
Skyscanner Software Engineer Algorithm - 0of 0 votes
AnswersSuppose you are in the middle of Africa, each machine is on an Edge network, and each packet between the machines costs $1.00. Write a solution that minimizes the cost.
- shing.zhao February 03, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Network - 0of 0 votes
AnswersYou are given as input on stdin the number of employees in a company and their direct line management relations between each other. Each person in the company can directly line-manage maximum 2 other employees. The input from stdin has the following format:
- twinmind February 02, 2015 in United Kingdom
1. on the first line, the number of employees
2. on the subsequent lines, the line management relations in the format «EmployeeM EmployeeN» - meaning EmployeeM manages EmployeeN (names are without spaces and spaces are used to separate the two names).
The input is correct (there are only direct management relations, no cycles).
For simplicity, the first line after the number of employees always contains the manager at the top of the hierarchy.
Write a program that reads the input file and then prints out the employees per level, in order of their importance (i.e. hierarchy):
Example:
Input:
6
Jon Mark
Jon David
Mark Paul
Paul Lee
Paul Steve
Output:
Jon
Mark David
Paul
Lee Steve
Input:
7
Jon Lee
Lee Paul
Paul Mark
Paul David
Lee Steve
Steve Mat
Output:
Jon
Lee
Paul Steve
Mark David Mat| Report Duplicate | Flag | PURGE
Skyscanner Software Engineer Algorithm - 0of 0 votes
AnswersWrite function to calculate sum of first N powers of 2 starting from 1. You shouldn't use any built-in function for calculating power. Implement the most efficient solution.
- twinmind February 02, 2015 in United Kingdom| Report Duplicate | Flag | PURGE
Skyscanner Software Engineer - 5of 5 votes
Answers
- skc25pma February 02, 2015 in India for Media.netA tree is given in which each edge is having some weight associated with it and you are given a number K. So starting from root in K-steps how much maximum weight you can collect. You can traverse in any direction either from parent to child or child to parent. You can visit a node multiple times. Eg: O 5/ \ 6 O O 24/ 1 \ \11 For K=1, ans=6 For K=2, ans=29 etc..
| Report Duplicate | Flag | PURGE
Directi Software Engineer - 1of 1 vote
AnswersYou toss a fair coin 400 times. What’s the probability that you get at least 220 heads? Round your answer to the nearest per cent.
- tihor February 01, 2015 in India for Strats| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer Math & Computation - 0of 0 votes
Answers#include<iostream>
- mukeshsharma787898 January 31, 2015 in United States
#include<stdio.h>
using namespace std;
int main()
{
int i=1;
printf("He");
do
{
while(i<5)
{
cout<<"Hello";
i++;
}
}
while(1);
}
What will be output of the program and why ??
class Demo
{
public static void main(String args[])
{
int i=1;
do
{
while(i<5)
{
System.out.println("Hello");
i++;
}
}
while(true);
}
}
what will be output of java program ??
how it diff ??| Report Duplicate | Flag | PURGE
Nivio Technologies Software Engineer C - 0of 0 votes
Answersdesign a video thumb up/down system at youtube scale. how to concurrent read/write, persistence, store, update....etc.
- rjrush January 30, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer System Design - 0of 0 votes
AnswersFind the top k frequent items in a stream of numbers .
- Rahul Sharma January 29, 2015 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer - 0of 0 votes
AnswersCompletely blew it on this question today.
- jsdude January 28, 2015 in United States
1.) Given an array, find the maximum difference between two array elements given the second element comes after the first.
For example.
array = [1,2,3,4,5,6,7]
We can take the difference between 2 and 1 (2-1), but not the different between 1 and 2 (1-2).
This question is super easy, I solved it within minutes of getting of the phone. I came up with an O(n^2) solution over the phone. My improved solution was O(n).| Report Duplicate | Flag | PURGE
Facebook Software Engineer Arrays