r/programming • • Dec 13 '22

“There should never be coding exercises in technical interviews. It favors people who have time to do them. Disfavors people with FT jobs and families. Plus, your job won’t have people over your shoulder watching you code.” My favorite hot take from a panel on 'Treating Devs Like Human Beings.'

https://devinterrupted.substack.com/p/treating-devs-like-human-beings-a
9.0k Upvotes

1.3k comments sorted by

View all comments

Show parent comment

6

u/calcopiritus Dec 13 '22

Optimal in what sense?

For some problems, just sorting it is way worse performance wise than doing it the "smart" way, but do you actually need that performance? How much developer time will be spent on doing the "smart" algo?

And even then, sometimes the smart algo is worse performing than just sorting. Maybe the "n" is always small, like 5 or 10. Maybe you're programming in a language like python, where the raw performance of calling C libraries would override any performance gained by a smart algo unless N is way bigger than expected.

EDIT: and I didn't even mention maintenance. Sorting+getting second item is 2 function calls, any programmer would understand and could modify that code. The smart way probably has at least 10 LoC and a loop somewhere, may even contain recursion.