Live data from Hacker News

Data structures and algorithms interview questions and their solutions

techiedelight.quora.com

1–10 of 36 posts

Re: Data structures and algorithms interview questions and their solutions

#5
post #4

Didn'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?

Thank you! It's really sad seeing what this field has turned into.

Re: Data structures and algorithms interview questions and their solutions

#6
If 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 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

#7
post #4

Didn'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?

I don't like coding interviews, but this list is for practice, not memorization. Ideally you could solve all of these from first principles.

Re: Data structures and algorithms interview questions and their solutions

#8
post #6

If 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 WTFs:

http://www.techiedelight.com/generate-binary-numbers-1-n/

Re: Data structures and algorithms interview questions and their solutions

#9
post #6

If 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/

"What I told you the question was either or" haha
Post reply on HN