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

1

u/HaMMeReD May 08 '15

You can eliminate a lot of cases. If you ever find 100, you can eliminate every neighbour from needing to be tested.

I'm sure there are more optimizations you could easily do.

2

u/Veedrac May 08 '15

If you ever find 100, you can eliminate every neighbour from needing to be tested.

Only on the leaf node, though, which is largely useless.

The only obvious speedup is to memoize (eg. dynamic programming.)

1

u/gliph May 08 '15

As pointed out, you're only talking about replacing a constant time calculation with another constant time calculation. This isn't going to be significant. You still need to do 3N constant time calculations.

The optimizations really needed (if this problem were generalized to sequences longer than 1...9) would reduce the number of cases checked.

1

u/HaMMeReD May 08 '15

Yeah, I was thinking about this, it wouldn't really do much I agree.