Data structures and algorithms interview questions and their solutions
techiedelight.quora.com
Data structures and algorithms interview questions and their solutions
1–10 of 36 posts
Re: Data structures and algorithms interview questions and their solutions
#2Re: Data structures and algorithms interview questions and their solutions
#3Re: Data structures and algorithms interview questions and their solutions
#4Re: Data structures and algorithms interview questions and their solutions
#5Didn't most of us get in to this mathsy line of work precisely because we didn't need to memorise a load of stuff and could just work things out from first principles as and when required?
Re: Data structures and algorithms interview questions and their solutions
#6"Implement multiplication without using loops."
"Uh, okay. What do you mean by loops?"
"Don't use a conditional loop."
"What do you mean by a conditional loop?"
"Oh, you know, the standard definition."
Time passes.
"I'm stuck. What is the answer?"
"Oh, you just have a loop on b dividing it by 2 using shift operators until it is zero."
"Wait a minute, you said you couldn't use loops."
"Did I? Ah, well."
Hackerrank/leetcode exercises are written the same way. So many times that a problem asks "Output the indexes of two numbers in the array such that their sum is K" and you write your code and the website says "INCORRECT! You said [3,6] but the right answer was [6,3]". Addition is commutative! The two are equal! And both right!
Re: Data structures and algorithms interview questions and their solutions
#7Didn't most of us get in to this mathsy line of work precisely because we didn't need to memorise a load of stuff and could just work things out from first principles as and when required?
Re: Data structures and algorithms interview questions and their solutions
#8If this isn't a metaphor for the programming interview I don't know what is: http://www.techiedelight.com/multiply-two-numbers-without-us... "Implement multiplication without using loops." "Uh, okay. What do you mean by loops?" "Don't use a conditional loop." "What do you mean by a conditional loop?" "Oh, you know, the standard definition." Time passes. "I'm stuck. What is the answer?" "Oh, you just have a loop on b…
That page is both hilarious and sad at the same time. Hilarious because the second "solution" clearly has a loop, and sad because sites like those don't really help anyone. Some of the pages on that site are downright WTFs:
Re: Data structures and algorithms interview questions and their solutions
#9If this isn't a metaphor for the programming interview I don't know what is: http://www.techiedelight.com/multiply-two-numbers-without-us... "Implement multiplication without using loops." "Uh, okay. What do you mean by loops?" "Don't use a conditional loop." "What do you mean by a conditional loop?" "Oh, you know, the standard definition." Time passes. "I'm stuck. What is the answer?" "Oh, you just have a loop on b…
The real way to multiply without loops is to use a lookup table, or unroll the (fixed iteration) shift-and-add loop. That page is both hilarious and sad at the same time. Hilarious because the second "solution" clearly has a loop, and sad because sites like those don't really help anyone. Some of the pages on that site are downright WTF s: http://www.techiedelight.com/generate-binary-numbers-1-n/
Re: Data structures and algorithms interview questions and their solutions
#10"Replace each element of array with product of every other element without using / operator"
use the / operator?
My solution would involve summing the log() of the values in the array.