Re:The best engineering interview question I've ever gotten
by ankrgyl on Sunday April 17, 2022 @08:36PM
(#31066006)
You hit the nail on the head. We explicitly did not care about how "well" the solution was written (some solutions were very surgical, others involved a lot of copy/pasta, some folks wrote very detailed comments, etc.), although we did point out and ask you to fix solutions that were incorrect. For example, some candidates implemented "mult" as "add" in a loop, with the row lock acquired and released in each iteration. This solution is vulnerable to a data race if another user concurrently updates the value.
[ Parent
| on HN ]
Re:The best engineering interview question I've ever gotten
by jwmoz on Sunday April 17, 2022 @11:30PM
(#31067049)
Can you explain why some would go down this loop route? I don't know C but the obvious solution to me is what you posted.
Re:The best engineering interview question I've ever gotten
by sverhagen on Sunday April 17, 2022 @11:35PM
(#31067097)
It seems a simple way of building the "mult" solution as a composition of the existing primitive(s), here "add". But agreed, that I would not find the tradeof acceptable either.
Re:The best engineering interview question I've ever gotten
by Sohcahtoa82 on Monday April 18, 2022 @01:04PM
(#31073460)
Forget the locking and data race problem...I think about the massive performance problem.
It turns multiplication into O(n) instead of O(log n). `mult 2000` would take 2000 times longer than `mult 2`.
Imagine being able to DoS a server just by asking it to multiply two numbers.
Re:The best engineering interview question I've ever gotten
by jseban on Monday April 18, 2022 @03:14AM
(#31068187)
> This solution is vulnerable to a data race if another user concurrently updates the value.
And this, of course, they are expected to understand in an unfamiliar code base with 3 hours total for the whole task. LOL
Re:The best engineering interview question I've ever gotten
by maccard on Monday April 18, 2022 @05:11AM
(#31068719)
No, not knowing that is a fundamental misunderstandings of either locks or scope. Depending on the role and job level that may be table stakes.
Re:The best engineering interview question I've ever gotten
by FartyMcFarter on Monday April 18, 2022 @04:32AM
(#31068537)
You don't need to see the rest of the codebase to realise that's probably wrong. In any codebase, locks only apply to the scope they're in.
Re:The best engineering interview question I've ever gotten
by jseban on Monday April 18, 2022 @05:02AM
(#31068672)
The key word here being "probably".
Re:The best engineering interview question I've ever gotten
by FartyMcFarter on Monday April 18, 2022 @05:07AM
(#31068697)
Yes - so the safe thing to do is to put the lock outside the loop. Anyone experienced in multithreading will instinctively know this is the correct alternative for any codebase (and it performs better too).