Quote:
Originally Posted by gaming_mouse
that said, i think when you're doing puzzles like these your habitual workplace constraints no longer apply
I'm not sure what you mean here then - what does it mean for something to be a "right" approach for a puzzle? Why does an answer to a puzzle have to any particular attribute, whether clarity or simplicity? Note how I went for the exact opposite in my answer
In production C code, you would not do this because it's a less efficient solution that requires far more lines of code to express and is much harder for C programmers to understand or review. In an interview situation, you're trying to demonstrate your ability to write clear, efficient code and that you understand runtime complexity. Code that offloads most of the responsibility to the libraries which the interviewer may or may not be familiar with, thus failing to demonstrate your ability to write code, which the interviewer wants to see, is counterproductive. Likewise, writing code with runtime characteristics that are worse than a naive solution - well if you could get the interviewer to even understand how your code is actually going to run - seems extremely counterproductive.