AmzFAILFacebookFailMSFTFail
BAN USERLooking for full time job.
- 0of 0 votes
Answers"DESCRIBE" and write code to return LCA of any two given nodes in __Binary Tree__.
- AmzFAILFacebookFailMSFTFail in United States for Windows Live!| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 0of 0 votes
AnswersPrint the binary tree level by level. Suggest methods. If one of your method is using queue and some delimiter is detect the change in levels, what is its space and time complexity. Prove your analysis. (yes, CLRS style proof is expected)
- AmzFAILFacebookFailMSFTFail in United States for Backend systems| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 0of 0 votes
AnswersGiven number n, return true if n is prime otherwise false.
- AmzFAILFacebookFailMSFTFail in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersWrite class for binary expression tree.
- AmzFAILFacebookFailMSFTFail in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersWhat is polymorphism, inheritance, method overriding.
- AmzFAILFacebookFailMSFTFail in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersCheck if two linked merge.
- AmzFAILFacebookFailMSFTFail in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersPrint odd powers of three.
- AmzFAILFacebookFailMSFTFail in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer
Yes, if you are told how many steps of rotations are done. Here it is unknown entity.
- AmzFAILFacebookFailMSFTFail January 20, 2012Yes, if you are told how many steps of rotations are done. Here it is unknown entity.
- AmzFAILFacebookFailMSFTFail January 20, 2012program works fine for any input.
really? I mean, REALLY? Your code is completely thrown off for large numbers and negative numbers.
PS: Take time, read the question and see if you need return something or SHOUT that you got output. And before claiming something big, be prepared to back it up!
@ NotThatBad: ≈≈≈Ω©√ç∂∂©ƒ∂©ƒ∂©ƒ∂√熃©ƒ©ƒ†ƒ''
Yeah! Just splitting code without explaining what the heck ran in your mind and how you came to this solution makes your interviewer or any reader who drops in here fell like above. Next time, remember, people dont care to just read some random code but to read some explanation!
Brute force approach:
int n1 = head.data
int n2 = head.next.data
head = head.next.next;
while(head!=null){
if(n1+n2 == givenSum){
a[0] = n1;
a[1] = n2;
return a;
}
else{
head = head.next;
n1 = head.data;
n2 = head.next.data;
}
}
I have lot of Indian classmates at my school. I did talk to them about using these kind of acronyms in verbal conversation. One of the friend said, "We do not know touch typing ( that is, to type without seeing keyboard) and hence tend to cut off the words to reduce the pain of switching from monitor to keyboard sight" and other said the same reason that we often see in US too - " lot of SMSing and tweeting". They left me thinking but they had the point.
- AmzFAILFacebookFailMSFTFail January 08, 2012Yes, make your assumptions explicit if you do not want to interviewer guessing what you thought about the problem
- AmzFAILFacebookFailMSFTFail January 08, 2012Nice! but fails for num = { -8, 9, 9}
Expected: - 8 9 8
Your program o/p: -7 9 9
I know we need small fix to the code to get this correct but just thought I'd let you know that you had made an assumption that numbers are always positive.
Are you sure this is for phone interview? It is extremely unlikely that you are asked to solve this problem in what is known as "facebook-45-min-technical" interview.
@topcoder99: can you confirm?
Yes! Initial k-d tree building takes O(NlogN). But I'm sure mentioning that k-d tree can be used in this kind of situations and discussing its pros and cons will sure get you extra credit in interview :-)
- AmzFAILFacebookFailMSFTFail January 06, 2012en.wikipedia.org/wiki/K-d_tree#Points_only_in_leaves
As said in above link, if the points are distributed randomly all across the space, we can do better than linear time with hacking around using method in the link.
PS: This may even qualify as a point-in-a-polygon variant and I'm not sure of its complexity. I'm off to flight now but will let you know if we can use this techinique as well.
Create an array of size 2n where is n is the size of object[]. If the size grows beyond, 2n/3 ( some threshold T), create a new array of size "3n" and copy the elements from overgrown array.
Add will to empty locations of the array while delete will be lazy delete. for each delete request, we should invalidate the data at that location and do not free up memory until there are enough cells that needs to be deleted.
Update should be trival in this case.
Disclaimer: Naive approach. Would love to see some awesome improved answers!
@Krest: It's getting too late here. I will try it tomorrow but I believe your logic sounds reasonable. Thanks for NOT just spitting code ( like python code below) but the actual algorithm! It was fun to learn AC algorithm!
- AmzFAILFacebookFailMSFTFail January 04, 2012@Krest - Ok! So the AC algorithm will build a nice trie like structure and allows to search for keyword presence on this built trie/dictionary. Of course, with that nice thing of "transitioning" to new nodes even with failures to match suffixes. No what is not clear to me is, after building the trie, how would you plan to use the AC algorithm to compress the keywords or infact the entire dictionary?
- AmzFAILFacebookFailMSFTFail January 04, 2012Did any one finish this question? Got the solution?
Can you walk me through your logic for this below matrix?
1 2 8 14
3 6 15 17
5 9 18 20
7 11 19 21
On a n bit machine, it will be as many bytes as the n bit address corresponds to. For example, on 32 bit machine, both will have 32 bit address and hence need 4 bytes each.
- AmzFAILFacebookFailMSFTFail January 01, 2012Is this really an in-person United States Google interview question? I was under impression that google and Microsoft has stopped asking puzzles! :-(
- AmzFAILFacebookFailMSFTFail December 31, 2011
BTW, on personal front, you seem to be good contributor to this site ( I'm quantifying you on your 300+ comments). What are you upto? Sophomore or junior or senior :) ?
- AmzFAILFacebookFailMSFTFail January 20, 2012