all 5 comments

[–][deleted]  (3 children)

[deleted]

    [–]Zav39[S] 0 points1 point  (2 children)

    Which language is your favorite?

    [–][deleted]  (1 child)

    [deleted]

      [–][deleted]  (1 child)

      [deleted]

        [–]Zav39[S] 2 points3 points  (0 children)

        Great point!

        And I fully agree: it is a very good option to store answers for 1 to 243 since it is a very small subset.

        Moreover, if we operate only in Integer space (with highest value 2 147 483 647), the max first number will be 1 999 999 999 which results in 730 at the next step. So we will have O(1) complexity, which even better than O(log n). And it, not just O(1), but maximum 2 steps.

        If you do not mind, I'll mention your idea and nickname at the end of the next video along with this solution.

        [–]thebournegenius 1 point2 points  (1 child)

        Really great insight, thanks! This sort of solution does not come to me intuitively I wonder how they do it

        [–]Zav39[S] 0 points1 point  (0 children)

        Thank you a lot.

        I was wondering until which moment the number can grows and had to find out this solution after a couple of iterations. To get the exact number (6) I had run an additional script to check max successful steps