3 ms·
You are correct, lines of code is nothing to do with the difficlty of the problem. I spent close to three weeks writing 12 lines of Python. Two of which consist
by justinlloyd 5y ago
You are correct, lines of code is nothing to do with the difficlty of the problem. I spent close to three weeks writing 12 lines of Python. Two of which consisted of print statements. A "clean-up" pass removed three more lines. I consider that to be some of the hardest code I've written in recent memory.
If I was asked to invert a binary tree on a whiteboard I would stumble too. Inverting a binary tree, I can walk through the algorithm, or I can bang out the code. And yes, it's three lines of code, but I had to look up what "invert a binary tree" means. Put a pen in my hand and I'd freeze up. It is trivial to solve through either recursion or iteration. I understand how to, but if I was asked to solve it in an interview, I'd definitely question why. I cannot think of a single instance whereby I'd want to legitimately flip a free left to right in its entirety. I can think of dozens of esoteric tree operations that I would need, and have used, but inverting/flipping left-to-right completely is not one of them.
I consider the person in that tweet far smarter than me.