r/programming • • May 08 '15

Five programming problems every Software Engineer should be able to solve in less than 1 hour

https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour
2.5k Upvotes

2.1k comments sorted by

View all comments

Show parent comments

37

u/Drolyt May 08 '15

I think you are over-thinking 4. Just brute force it: find all the possible concatenations and then use the max function your language most likely provides. You can find an efficient way to do it after the hour is up.

13

u/KFCConspiracy May 08 '15

I'd probably question that pretty hard and make the candidate rewrite that in a non-brute force manner.

13

u/conflare May 08 '15

"The requirements placed a priority on time to market, so I optimized for that."

But I would feel dirty.

3

u/hpp3 May 08 '15

In my experience with interviews like this, that bullshit won't fly. If the interviewer has an elegant runtime in mind, s/he's looking for that runtime, and you'll get prompted and prodded ("is there a better solution?") until you give a solution with that runtime or you give up.

The only question here where brute force is acceptable is #5 because 1) there isn't a better way to do it and 2) you are given an explicit bound.

→ More replies (2)