Software Engineer Interview Questions
- 1of 1 vote
AnswersGiven multiple strings like "candy", "carry", "dummy", etc. These strings are stored as c3y, c3y and d3y etc. Write a function which returns a boolean if the string (like "carry" is unique in the dictionary)
- AirWind April 15, 2016 in United States
bool
isUniqueDictionaryWord(char *str)
If the strings are in a file and you load it when the program loads, how will you store it ?| Report Duplicate | Flag | PURGE
Google Software Engineer Hash Table - 1of 1 vote
AnswersGiven a string S, print the longest substring P such that P > S lexicographically.
- emb March 16, 2016 in United States
You may assume that such substring exists.| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersGiven an arbitrary tree starting at “root” where each node contains a pair of values (x, y), write a boolean function find(Node root, int x, int y) that returns true iff
- Basu March 08, 2016 in United States
* x is equal to a value "x" of any node n1 in the tree
* and y is equal to a value "y" of any node n2 in the tree
* and both n1 and n2 are at the same level in the tree
boolean find(Node root, int x, int y)
Example:
(1,120)
/ | \
/ | \
/ | \
(5,15) (30,70) (80,110)
/ | \ |
/ | \ |
/ | \ |
(35, 40) (45,50) (55, 65) (90, 100)
boo == true
find(root, 45, 100) == true
find(root, 30, 100) == false
find(root, 30, 70) == true
find(root, 70, 30) == false| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersGiven a histogram chart with values say {5,4,3,6,0,1}. Get the total count required to completely melt the histogram. A column with value 5 has 5 blocks in it. Any block which has air on any of its side gets melted.
- abc_abc March 07, 2016 in United States
Sample 1
{5,4,3,6,0,1} - > {0,3,2,0,0,0}->{0,0,0,0,0,0} => count=2
Sample 2
{0,1,1,1,1,0} - > {0,0,0,0,0,0} => count=1| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer Arrays - 1of 1 vote
AnswersGiven a 2D matrix of integers, sort it such that:
- every row is sorted in ascending order from left to right
- every column is sorted in ascending order from top to down
- all items in the same row are unique
You may assume the input matrix is always valid, meaning that such a sort is always possible.
For example:
for input matrix1 3 5 3 2 4
the output could be any of the following:
valid output #1:1 3 4 2 3 5
valid output #2:
1 2 3 3 4 5
valid output #3:
1 3 4 2 3 5
One kinda trivial solution is to sort the 2D matrix column wise. For example, you can push all items into a heap and pop one after another, putting it into the matrix column after column. This would be a `O(n lg n)` time complexity where `n` is the number of items in the matrix, i.e., `n = rows*cols`. Can you design a more efficient algorithm?
- zhtt2009 February 29, 2016 in United States
Follow-up: What if all items in the same column are also required to be unique?| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersGiven an array and a number, add it in such a way where array is [0,0,1] and number is 4 output will be [0,0,5]
- Ipalibo February 25, 2016 in United Kingdom
Example 2 :
array is [1] and number is 9 output will be [1,0]| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 1of 1 vote
AnswersGiven a string where in each word letters were randomly shuffled and after that words were written without spaces (lets call it X). Also you have a dictionary. The task is to return all possible strings S that can be transformed into the string X and all words in S are from dictionary.
- golyjivan February 19, 2016 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 1of 1 vote
AnswersSecond Least common element from an Integer array.
- PS February 08, 2016 in United States
Example:
[5,5,4,5,4,6,6,6,1,3,3,4,4,5,4]
Answer: 3
Reason: {1=1, 3=2, 4=5, 5=4, 6=3}| Report Duplicate | Flag | PURGE
Bank of America Software Engineer Algorithm - 1of 1 vote
AnswersRemove duplicates from string given " cutcopypaste " Return "uoyase"
- ajju February 05, 2016 in India| Report Duplicate | Flag | PURGE
Accenture Software Engineer - 0of 0 votes
AnswersImplement following interface so that multi-put is atomic. Expect multiple producers and consumers inserting to and extracting from this queue implementation.
- scgupta January 30, 2016 in India
/**
* threadSafe bounded blocking queue implementation. Expected to be used in a
* Producer->Consumer pattern
*/
public interface MultiPutBlockingBoundedQueue<E> {
/**
* Sets the capacity of the buffer. Can be called only once. If called more
* than once or if the passed capacity is <= 0, throw an exception.
*/
public void init(int capacity) throws Exception;
/**
* Get the next item from the queue throws Exception if not initialized
*/
public E get() throws Exception;
/**
* Put the item to the tail of the queue. throws Exception if not
* initialized
*/
public void put(E obj) throws Exception;
/**
* Put the list of items in an atomic manner. The list can be more than the
* capacity throws Exception if not initialized
*/
public void multiput(List<E> objs) throws Exception;
}| Report Duplicate | Flag | PURGE
Linkedin Software Engineer Java - 1of 1 vote
Answershow can i merge 2 nodes in a graph in 1 node , need to save the in and out edges and the nodes that was merged for contribution after that
- KabhaD82 January 30, 2016 in United States
for example a graph implementation in adj list:
1->3->4->6
2->3->4->6
5->4->6
and i want to merge the nodes 3 and 4 , then new nodes should be created 7 as :
1->7->6
2->7->6
5->7->6
7->6
the node 7 also will save [include 3,4 the merged nodes]
any one can help with that please
typedef struct AdjListEntry {
int visited;
int index;
struct AdjListNode current; // node iniformation
struct AdjListEntry* next;
} AdjListEntry;
typedef struct AdjListNode {
int Uind;
char name[10];
char label[10];
adjOutEddgeLists *outEddges;
//adjInEddgeLists *inEddges;
} AdjListNode;
typedef struct adjOutEddgeLists{
AdjListNode *listNode;
adjOutEddgeLists *next;
}adjOutEddgeLists;| Report Duplicate | Flag | PURGE
Amazon Software Engineer C - 0of 0 votes
AnswersImplement a Qsort similar to the build in one in C, but use an insertion sort instead
- J@sper January 30, 2016 in United States
void GoogleSort(void *ptr, int number, int SIZE, int (*functionp)(const void *, const void *)) {
}| Report Duplicate | Flag | PURGE
Google Software Engineer C - 1of 1 vote
AnswersIf you have 1TB of unsorted long integers but 1GB of memory, devise an algorithm to efficiently sort the integers. What is the time complexity? What is the space complexity?
- popeye123 January 29, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 0of 0 votes
AnswersFind the length of a maximum palindrome subset in an array. For example: in 1, 2, 4, 1 the maximum palindrome subset is 1, 2, 1 and the answer is 3
- dlyakolesa January 27, 2016 in United States| Report Duplicate | Flag | PURGE
Linkedin Software Engineer Algorithm - 0of 0 votes
AnswersImplement a function which modifies a binary tree so that the output is the tree that is a mirror of an input tree
- dlyakolesa January 27, 2016 in United States| Report Duplicate | Flag | PURGE
Linkedin Software Engineer Algorithm - 0of 0 votes
Answer1) What is transaction
- dlyakolesa January 27, 2016 in United States| Report Duplicate | Flag | PURGE
Linkedin Software Engineer Computer Science - 0of 0 votes
AnswersWrite a program to check if a chess move is valid. The api should be extendible to cover cases like castling and pawn promotion.
- ffish January 25, 2016 in India| Report Duplicate | Flag | PURGE
Flipkart Software Engineer Coding - 5of 5 votes
AnswersYou are given a function bool rand_bit_p() that returns true with some unknown probability p and false with probability 1 - p.
- emb January 24, 2016 in United States
Write function rand_bit() using rand_bit_p that will return true and false with equal probability (that is, implement a fair coin, given unfair coin)| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
Answers-How would you design Google Analytics (there are huge number of users and we need real-time analysis report)?
- Matt Chad January 20, 2016 in United States
-How would you detect trends?| Report Duplicate | Flag | PURGE
Google Software Engineer Large Scale Computing - 0of 0 votes
AnswersMerge two sorted singly linked lists into one sorted singly linked list. Allocate no extra node.
- Saurabh Singhal January 16, 2016 in India| Report Duplicate | Flag | PURGE
Arista Networks Software Engineer Data Structures Linked Lists - -1of 1 vote
AnswersSuppose a nxn chessboard has two diagonally opposite corners removed, leaving n^2-2 squares. Is it possible to place (n^2-2)/2 dominoes of size 2x1 so as to cover all of these squares?
- Saurabh Singhal January 16, 2016 in India| Report Duplicate | Flag | PURGE
Arista Networks Software Engineer - 0of 0 votes
AnswerProgram to check whether 2 rectangles in a 2 D plane overlap or not.
- Saurabh Singhal January 16, 2016 in India| Report Duplicate | Flag | PURGE
Arista Networks Software Engineer General Questions and Comments - 0of 0 votes
AnswerGiven a sorted integer array. Convert it to a balanced BST (Size of array is given)
- Saurabh Singhal January 16, 2016 in India| Report Duplicate | Flag | PURGE
Arista Networks Software Engineer Data Structures Trees and Graphs - 0of 0 votes
AnswersAllocate a 2-D array of size m*n using malloc(). The array should be accessible as a[i][j].
- Saurabh Singhal January 16, 2016 in India| Report Duplicate | Flag | PURGE
Arista Networks Software Engineer Arrays C Data Structures Matrix - 3of 3 votes
AnswersGiven 4 teams and 3 gamedays, create an algorithm such that each team plays another team every gameday and by the end of the 3 game days each team should have played one game with every other team.
- popeye123 January 03, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm Problem Solving - 0of 0 votes
AnswersGiven an array of ints (positive numbers) find out the index that balances the array. If no such index exists, return the index that minimizes the difference.
- tamashionuth January 02, 2016 in United States
How can you do it by touching each element only once.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm - 0of 0 votes
AnswerInsert an int into a circular single linked list.
- tamashionuth January 02, 2016 in United States
Discuss corner cases: what if the element to be inserted is the smallest, how can we speed things up (e.g. if the method is called multiple times you can keep track of the "last"/greatest element).
Thorough testing discussions.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm - 0of 0 votes
AnswersHow to sort a very large array (>50GB int array) stored on disk given that you have a 200MB RAM memory.
- tamashionuth January 02, 2016 in United States
Discussions on this: test it, corner cases, etc.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 2of 2 votes
AnswersGiven a number (integer) as a string turn in into a number:
- tamashionuth January 02, 2016 in United States
E.g. "One million two hundreds thousands fifty seven" => shoud return 1200057.
How to model it and how to test it? What data structures would you use. Deep testing (corner cases)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm