Dev Lead Interview Questions
- 0of 0 votes
AnswersGiven a set of road segments:
- wizkid November 07, 2014 in India
class Seg { int ID; int NextID; }
Implement a method that finds the longest connected stretch for a random collection of segments:
Seg[] FindLongest(Seg[] segs);
Assume that each NextID have a corresponding object with ID == NextID in the input. (-1 or any negative ID) indicates no link. No other assumptions about input should be made| Report Duplicate | Flag | PURGE
Dev Lead Dev Lead - 1of 1 vote
AnswersTwo dices are tossed. Once die is regular and the other is biased with probabilities P(1) = P(6) = 1/6, P(2) = P(4) = 0, P(3)= P(5) = 1/3.
- jatson October 03, 2014 in United States for Kindle
Determine the probabilities of obtaining the sum 4.| Report Duplicate | Flag | PURGE
Amazon Dev Lead Dev Lead Math & Computation - 0of 0 votes
AnswersFind the permutation of a given string using dynamic programming . Try to do with the best possible time complexity and space complexity .
- AlgoBaba September 27, 2014 in India| Report Duplicate | Flag | PURGE
Amazon Dev Lead Dev Lead Algorithm - 0of 0 votes
AnswersGiven a Tree (binary and unbalanced)
- argho.chatterjee.001 September 18, 2014 in United States for Software development engineer II
Find all the nodes in that tree which are 'n' levels up the leaf node...
Eg:
A->root
A.left=B
A.right=C
B.left=D
B.right=E
C.right=F
D.right=G
then
if 'n' as described in the above problem statement, is say n=2
then
answer should be :
B(2 nodes up from G), A(2 nodes up from E & F)
hence ans is B,A
My Algo was;
1)Perform a DFS (left,middle, right)
2) when leaf node is encountered.. just move the stack pointer (without poping or jsut coy the stack of DFS to another stack and perform a real time pop operation) by 'n' times and then just print the node which it encounters.
code:
int n=2;
Stack treeStack = new Stack();
function find(){
treeStack .push(rootnode);
performDFS();
}
function performDFS(){
if(currnetnode.left==null && currentnode.right==null){
// this is a leaf node.
Stack tmpStack=copyStack(treeStack);
// hard coded logic(two pop operations) without using a loop since i am usnig n=2 in //this example
tmpStack.pop(); // pop 1st element
element = tmpStack.pop(); // print the 2nd element
print(element);
}
if(currnetnode.left!=null)
treestack.push(currentnode.left);
if(currnetnode.right!=null)
tree.stack.push(currentnode.right);
}| Report Duplicate | Flag | PURGE
Amazon Dev Lead Dev Lead Algorithm - 0of 0 votes
AnswersGiven an array of positive negative no, u need to find max sum we can achieve using this array, condition is u cannot use two adjacent items.
- Kavita August 06, 2014 in India
Print sum in one line
Print all items that contribute this sum in other line using space separated char
if all items r negative then print least negative no
-1 4 5 -2 -6 6
output-
11
5 6
we want it inplace and linear time.
Focus on printing items that contribute max sum.| Report Duplicate | Flag | PURGE
Citrix System Inc Dev Lead Dev Lead - 0of 0 votes
AnswersSuppose u have a buffer of size 1024 byte, and there are m writer thread that will write on this buffer, if a writer get a chance to write on buffer it will completely fill it. If buffer is already written then no other writer thread should be able to write data on it till buffer is not processed by readers threads. There are n reader threads.
- Kavita July 14, 2014 in India
if buffer is full then one of reader thread should able to read it and make empty then again one of writer thread fill buffer.
buffer completely filled in single shot it mean if writing started it be completed fully.
Write a solution so all writer thread get equal chance to write on buffer and same way all readers threads get equal chance to read data from buffer.
Ex- if 3 writer and 3 reader
after 3 time write operation every thread done 1 time write operation and same way each reader also 1 time processed data.
Any more info u need ask me....| Report Duplicate | Flag | PURGE
KLA Tencor Dev Lead Dev Lead - 0of 0 votes
AnswersWhat is composite key? How it differs from candidate key?
- kaustubh deshmukh June 19, 2014 in India| Report Duplicate | Flag | PURGE
TATA Consultancy Services Dev Lead Dev Lead SQL - 0of 0 votes
AnswerHow we can implement final classes in C++, We should be able to create
- Kavita June 13, 2014 in India
.object but other class if try to inherit compiler should flag error...| Report Duplicate | Flag | PURGE
Dev Lead Dev Lead - 0of 0 votes
AnswerWhen compiler fails to write a copy constructor for u even if u not write any copy constructor
- Kavita June 13, 2014 in India
Test t1 = Test();
Test t2 = t1; //error| Report Duplicate | Flag | PURGE
Dev Lead Dev Lead - 0of 0 votes
Answers#include<iostream>
- Kavita June 11, 2014 in India
using namespace std;
const char* fun()
{
const char* str = "This is test string";
return str;
}
int main()
{
const char* p = fun();
while(!p != '\0')
{
cout<<*p;
p++;
}
return 0;
}
Is there any problem with this code...what will be the output of this problem?? if there is any error then why...and if it work fine then why??| Report Duplicate | Flag | PURGE
Dev Lead Dev Lead - 1of 1 vote
AnswersYou are asked to code an Android game that shows this board
+——————————+——————————+ |1 | 2| | | | | ♠ | ♣ | | +———+———+ | | | ♥ | ♠ | | +——————+———+———+——————+ | | ♦ | ♣ | | | +———+———+ | | ♥ | ♦ | | | | |3 | 4| +——————————+——————————+
Where the numbers are text but the spades, diamond, etc are graphics.
- diegum June 06, 2014 in United States for Android
The four squares in the center of the board are buttons. When you press any of these buttons, a popup shows buttons from 1 to 4. You have to click the number that makes your original button to match the quadrant whose symbol is the same.
So, in the figure, if you pressed the spades button, then you should press the button labeled 1. If you pressed the heart button then you should press 3, etc.
When you press the buttons correctly, the figure button is swapped properly so it gets in the quadrant containing that figure, and disabled for further push.
If the number button were incorrect instead, the original figure button is swapped with the figure button at the quadrant whose number you erroneously clicked.
The game finishes when all figure buttons are in their correct quadrants. Last but not least, the figure buttons are initially placed randomly.
Describe how you'd put this board in a layout that doesn't distort the figures neither in quadrants nor in buttons.
Explain how you'd code the most important portions of this game.| Report Duplicate | Flag | PURGE
Starbucks Dev Lead Dev Lead Application / UI Design