

How to solve HackerRank's 20/20 hack challenges - rvivek
https://www.hackerrank.com/blog/2020editorial

======
cd444v
I looked over a bunch of the top ranking solutions on the leaderboard for
Alien Languages and over 90% of the solutions that ranked 1 used the integer
20 in their loops. for example, username test123test123
used---------------------------------------------

for (int k = 0; k <= i and k <= 20; k ++)

username damian_straszak used-----------------------------------------

for(int i=0;i<20;i++)

Khongor
used-------------------------------------------------------------------

for (int i = 1; i <= 20; i++)

XaCaHaa
used-------------------------------------------------------------------

define MATRIXN 20

for (int i = 0; i < MATRIXN; i++)

Where did this number come from? Did it come from some type of algorithm? I
saw so many of the top scored codes use this and I am baffled at how they came
up with the use of the number 20. I have looked over and over this problem and
I don't understand how they came up with the use of 20. I read the editorial
done by megaterik on the hackerrank blog on how they came up with their
solution (which they choice to do in Java, while I used C++) but yet they also
used 20 and never mentioned why they used 20 in the editorial. I would love to
know how they came up with the use of the number 20 for their solution.

~~~
hnuser1
It's a constant upper bound for lg N, which is shown in the editorial for the
maximum subword length. It's easy to remember 2^20 > 1e6 > 1e5, which helps
simplify the thought process behind the implementation.

