You, leetcode

LeetCode 2279 (Easy). Strong Password Checker II

With "easy" LeetCode problems, the challenge for me isn't finding a solution but rather:

What made this problem worth posting in the LeetCode forum was the deep dive into the OpenJDK 17 source code to point out how programming language builtins frequently cost more CPU cycles than rolling your own methods. In this case, I suggested using a hand-rolled isDigit() method instead of the Character.isDigit() that comes builtin with Java. I had never looked up the source for isDigit(), and it was interesting to see how this JDK did it.

Of course there are tradeoffs. The JDK isDigit() checks for Unicode vs. 0-255 ASCII, for instance. If you want checks and safety, you're better off using the methods that come with the language. But if you're willing to unbuckle your seatbelt, you can probably speed things up.

The code listing and forum post are here: