unknown Interview Questions
- 2of 2 votes
AnswersHow to find middle element in a linked list without knowing the length of the linked list
- D PRAVEEN KUMAR December 10, 2015 in India| Report Duplicate | Flag | PURGE
unknown Applications Developer Data Structures - 2of 2 votes
AnswersYou know result of a soccer match, print all the possible ways that this game ends up with this result.
- u-11i24223 December 01, 2015 in United States
Example: final score 1 - 1:
0 - 0
0 - 1
1 - 1
0 - 0
1 - 0
1 - 1
Another example if the final score is 2 - 3 there are many possibilities for reaching to that score:
2 - 3
0 - 0
1 - 0
2 - 0
2 - 1
2 - 2
2 - 3
0 - 0
1 - 0
1 - 1
1 - 2
2 - 2
2 - 3
0 - 0
0 - 1
0 - 2
0 - 3
...| Report Duplicate | Flag | PURGE
unknown Software Engineer Algorithm - 0of 0 votes
AnswersFind the largest substring in s1, such that all characters in the substring are present somewhere in s2
- johnsvakel November 20, 2015 in India| Report Duplicate | Flag | PURGE
unknown SDE-2 Algorithm - 5of 5 votes
AnswersAsked me to write an API. Then ask:
- joyfeng November 19, 2015 in United States
Consider how the API could support 3rd party applications which need to perform some logic based on the structure and content of a filter in a type-safe manner.| Report Duplicate | Flag | PURGE
unknown Software Engineer / Developer Java - 0of 0 votes
AnswerIt is part of a programming exercise.
- joyfeng November 19, 2015 in United States
Input is a combination of arbitrary complex filters. For example:
name = "smith" AND age > 9 OR Not(city = "New York")
It asks for a string representation, including the ability to generate and parse filters from the string representation. (you are not required to implement the string parsing logic since this could take too long)
Hint: give an example of a tree data structure.| Report Duplicate | Flag | PURGE
unknown Software Engineer / Developer Java - 0of 0 votes
AnswersGiven an array of integers of unknown size, how to reverse the order of the positive integers?
- ur2cdanger November 16, 2015 in United States
Ex [4 3 8 9 -2 6 10 13 -1 2 3 .. ] =>
[ 9 8 3 4 -2 13 10 6 -1 3 2]| Report Duplicate | Flag | PURGE
unknown Software Engineer Algorithm - 0of 2 votes
AnswersThe "Island Count" Problem
- rasmiranjanbabu November 10, 2015 in United States
Given a 2D matrix M, filled with either 0s or 1s, count the number of islands of 1s in M.
An island is a group of adjacent values that are all 1s. Every cell in M can be adjacent to the 4 cells that are next to it on the same row or column.
Explain and code the most efficient solution possible and analyze its runtime complexity.
Example: the matrix below has 6 islands:
0 1 0 1 0
0 0 1 1 1
1 0 0 1 0
0 1 1 0 0
1 0 1 0 1| Report Duplicate | Flag | PURGE
unknown xyz Algorithm - 0of 0 votes
AnswersFind the nth Fibonacci Prime, in the shortest code
- kesavan August 19, 2015 in India| Report Duplicate | Flag | PURGE
unknown Software Developer - 0of 0 votes
AnswersA paper consists of a series of consecutive numbers from 1 up to 2^n values. For example,
- vasanthvpsgece June 30, 2015 in India
For case 2^1, content of the paper is,
1 2
For case 2^2, content of the paper is,
1 2 3 4
For case 2^3, content of the paper is,
1 2 3 4 5 6 7 8
There will be n number of commands for 2^n case. Below are the commands,
L – Fold the paper from Left edge to Right edge
R – Fold the paper from Right edge to Left edge
After performing the n number of commands, there will be a single number in all layer of paper, you need to write down the numbers in all layers when you see the paper from upside of it.
Please provide an efficient algorithm.
Example:
Content of the paper (2^3):
1 2 3 4 5 6 7 8
Commands: LRL
Output:
5 4 1 8 7 2 3 6| Report Duplicate | Flag | PURGE
unknown Senior Software Development Engineer Algorithm - 0of 0 votes
AnswersHow will you test an application like Google Analytics ?
- zammer June 14, 2015 in India| Report Duplicate | Flag | PURGE
unknown SDET Testing - 0of 0 votes
AnswerWhat are the basic features you will add into your own test framework ?
- zammer June 14, 2015 in India| Report Duplicate | Flag | PURGE
unknown SDET Testing - 0of 0 votes
AnswersWhich structure can be used to return the lastly added node and remove it from the collection and also will allow to peek the highest valued node without removing it from the collection. What is the time and space complexity for Push, Pop and Peek actions
- A3Clef May 08, 2015 in United States| Report Duplicate | Flag | PURGE
unknown Software Developer Data Structures - 0of 0 votes
AnswersSuppose you have a huge data of students. This data is in RAM (around 48 GB). Student has following attributes:
- guptasunny158 March 20, 2015 in India
1) RollNo
2) Name
3) Address
Now I need to implement three method:
getStudentByRollNo(int rollno)
getStudentsByName(String name)
getStudentsByAddress(String address)
In what data structure I can keep these students so that these methods can return the results really fast.| Report Duplicate | Flag | PURGE
unknown Member Technical Staff Data Structures - 2of 2 votes
AnswerThe problem gives you a sample input data file containing the all the employee-employer relationship information of a company. For example "Peter, John, 2013, software developer--John, NULL, 2012, CEO--David, Peter, 2014, technician..." means there are 3 people int this company (segmented by '--' ), the first 1 is Peter, his boss is John, he entered the company in 2013 as a software developer. The second is John as CEO, with no boss, the third is David as technician, his boss is Peter. The problem is asking to output information in hierarchy style
- dknguyen13 February 28, 2015 in United States| Report Duplicate | Flag | PURGE
unknown Software Developer Java - 0of 0 votes
AnswersYou're the guard of a prison, you want to keep an eye on the most dangerous prisoner. Each prisoner has a danger rank of his own and a group of friends (prisoners, who also have danger ranks). The guard has a list of prisoners with their corresponding danger ranks and he also has a list of the friends of each of the prisoners in the prison.
- Sai February 03, 2015 in United States
The danger rank is computed as follows: Prisoner 1 has a danger value of 5, his friends are Prisoner 2 and Prisoner 5, who have danger values of 3 and 4 respectively. So the danger value of Prisoner 1 is 5+3+4 = 12.
There could be any number of prisoners. Whichever prisoner has the highest value is the most dangerous(computed using the above method).
Friendship can be assumed to be symmetric.
Come up with an efficient algorithm to find the most dangerous prisoner?
The solution I came up with runs in quadratic time.
A hash table which has the Prisoner as Key and list of his friends as value
Compute the sum of danger rank of all friends one key at a Time. (n * N)
Maintain a max count and update it as necessary.
I believe there is a solution for this problem having better time complexity than O(N^2).| Report Duplicate | Flag | PURGE
unknown Algorithm Problem Solving Puzzle - 0of 0 votes
AnswerOperation :Deleting element in the binary search tree(Without linked list) I'm trying to implement a pseudo-code but operation not implemented.can cause?(If you want I can write a pseudo-code.)So,delete operation is not happening for BST.can cause?-1 is null element in array. Linked list is not be for this code.
- maxflow34 March 11, 2014 in turkiye
void deleting(int *Tree,int element){
int temp=0;
while((Tree[temp]!=element) && (Tree[temp]!=-1)){
/*loop until the element is found*/
if(element<Tree[temp])
temp=2*temp+1;
else
temp=2*temp+2;
}
if(Tree[temp]!=1)/* if the element is found*/
/*case1 - Delete leaf node*/
if((Tree[2*temp+1]==-1) && (Tree[2*temp+2]==-1))
Tree[temp]=-1
/*case 2- delete node with one child*/
else if((Tree[2*temp+1]==-1)|| (Tree[2*temp+2]==-1)){
if(Tree[2*temp+1]!=-1) /* is the child in the left of temp*/
preOrder((2*temp+1),Tree);
else
preOrder((2*temp+2),Tree);
}
/*case 3-delete node with 2 children*/
else if {
int inOrder_N=2*temp+2 /* inorder successor is surely in the right sub tree*/
while(Tree[2*inOrder_N]!=-1)
inOrder_N=2*inOrder_N;
Tree[temp]=Tree[inOrder_N]; /* replace with inorder successor*/
if(Tree[2*inOrder_N+2]==-1);/* inorder successor has no child*/
Tree[inOrder_N]=-1;
else /* inorder successor has no child*/
preOrder(((2*inOrder_N)+1),Tree)
}
else
printf("element not found");
}
void preOrder(int node, int *bst,int n){
if(node<n){
printf("Node : %d - Value : %d \n",node,bst[node]);
preOrder(2*node+1,bst,N);
preOrder(2*node+2,bst,N);
}
return;
}| Report Duplicate | Flag | PURGE
unknown Student student 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 - 0of 0 votes
AnswersI have an unordered array of nodes. Each node has an id and parent_id. I want to pretty print out the nodes in an expanded format.
Assumptions:
There is only one root node in the array.
Don't worry about the white space.
Node has a toString() method.
All the ids are arbitrary and unique.
This is a tree and not a graph.
For example:
Sample input:
[{parentId: F, id:G}, {parentId: E, id: F}, {parentId: A, id: B}...]A (parent_id = null) B (parent_id = A) C (parent_id = B) D (parent_id = C) H (parent_id = B) E (parent_id = A) F (parent_id = E) G (parent_id = F)
Sample output:
- anonymous November 26, 2013 in United States
ABCDHEFG
Please write a more optimized solution and tell me the complexity.| Report Duplicate | Flag | PURGE
unknown Software Engineer / Developer Data Structures - 0of 0 votes
AnswersI have an unordered array of nodes. Each node has an id and parent_id. I want to pretty print out the nodes in an expanded format.
- anonymous November 26, 2013 in United States
Assumptions:
There is only one root node in the array.
Don't worry about the white space.
Node has a toString() method.
All the ids are arbitrary and unique.
This is a tree and not a graph.
For example:
Sample input:
[{parentId: F, id:G}, {parentId: E, id: F}, {parentId: A, id: B}...]
A (parent_id = null)
B (parent_id = A)
C (parent_id = B)
D (parent_id = C)
H (parent_id = B)
E (parent_id = A)
F (parent_id = E)
G (parent_id = F)
Sample output:
ABCDHEFG
Please tell me the naive solution and its complexity.
Please write a more optimized solution and tell me the complexity.| Report Duplicate | Flag | PURGE
unknown Software Engineer / Developer - 0of 0 votes
AnswersThere are 1000 balls in a bag, of which 900 are black and 100 are white. I randomly draw 100 balls from the bag. What is the probability that the 101st ball will be black?
- mohit May 05, 2012 in India
a)9/10 b)More than 9/10 but less than 1 c)Less than 9/10but more than 0 d)0 e)1| Report Duplicate | Flag | PURGE
unknown Student student Probability - 0of 0 votes
AnswersAmar and Akbar both tell the truth with probability 3/4 and lie with probability 1/4. Amar watches a test match and talks to Akbar about the outcome. Akbar, in turn, tells Anthony, "Amar told me that India won". What probability should Anthony assign to India's win?
- mohit May 05, 2012 in India
a)9/16 b)6/16 c)7/16 d)10/16 e)None of the above| Report Duplicate | Flag | PURGE
unknown Student student Probability - 0of 0 votes
AnswersLambda expression .Where() is more efficient than foreach loop?
- chandanchoubey March 17, 2012 in New Zealand| Report Duplicate | Flag | PURGE
unknown Software Engineer / Developer C# - 0of 0 votes
AnswersLambda expression .Where() is more efficient than foreach loop?
- chandanchoubey March 17, 2012 in New Zealand| Report Duplicate | Flag | PURGE
unknown Software Engineer / Developer C# - 0of 0 votes
AnswersLambda expression .Where() is more efficient than foreach loop?
- chandanchoubey March 17, 2012 in New Zealand| Report Duplicate | Flag | PURGE
unknown Software Engineer / Developer C# - 0of 0 votes
AnswersLambda expression .Where() is more efficient than foreach loop?
- chandanchoubey March 17, 2012 in New Zealand| Report Duplicate | Flag | PURGE
unknown Software Engineer / Developer C# - 0of 0 votes
Answerswrite a program to find min and max element in queue using linked list
- vaish1975 February 14, 2012 in India| Report Duplicate | Flag | PURGE
unknown Personnel Data Structures - 0of 0 votes
Answerswrite a program to find min and max element in stack using linked list
- vaish1975 February 14, 2012 in India| Report Duplicate | Flag | PURGE
unknown Personnel Data Structures - 0of 0 votes
AnswersQuestion from Sony USA:
- Kiran July 19, 2011
Without use of other function calls, rewrite this code to
ensure the pointer p is aligned to a 16-byte boundary for
its lifetime:
char *p = malloc(1024);
...
free(p);| Report Duplicate | Flag | PURGE
unknown Software Engineer / Developer - 0of 0 votes
AnswersBest way to share a large file to 1000 computers in the same network.
- Montegobay March 11, 2011| Report Duplicate | Flag | PURGE
unknown Software Engineer / Developer