OG said:
The idea of a "code challenge" is to challenge you, not us!
I completely agree.
Efficiency of solutions:
Simple minded solutions: are the slowest, they are usually brute force.
Clever solutions: are the fastest. They usually combine algorithms in a unique fashion to solve the challenge.
Fastest solutions imply a vast knowledge of algorithms and how to combine them to get solution that match the challenge.
Quote:
It would be of great help if someone explained it.
That explanation will take a vast amount of time to study this code, and will be of very little or no use to you, because of your lack of knowledge of algorithms, and because you will probably never reuse that particular solution.
Knowing an algorithm is not knowing its name, it is knowing what it does and having a good idea of how it does it, having experimented with examples is mandatory for a good understanding.
- Learn Algorithms and Data-Structures.
GitHub - The-Art-of-Computer-Programming-Books: "Everyday life is like programming, I guess. If you love something you can put beauty into it." ? Donald E. Knuth[
^]
Skiena The Algorithm Design Manual