Please turn JavaScript on
header-image

Another Casual Coder

Receive updates from Another Casual Coder for free, starting right now.

We can deliver them by email, via your phone or you can read them from a personalised news page on follow.it.

This way you won't miss any new article from Another Casual Coder. Unsubscribe at any time.

Site title: Another Casual Coder

Is this your feed? Claim it!

Publisher:  Unclaimed!
Message frequency:  1.4 / week

Message History

Backtracking is a powerful strategy, and yes if can become exponential even with pruning, but remember that exponential might still be acceptable depending on the size of the input. For instance, in this case there isn't a lot of pruning and the solution ends up being N^4, but N = 15 in this case which is about 50K iterations which is for all practical purposes a "linear" sol...


Read full story

Happy 2026. First problem is a medium difficulty, just use frequency count (hint is that we're dealing only with lowercase letters). Also make sure to use long to avoid overflow. Code is down below, cheers, ACC.

Minimum Dele...


Read full story
Prefix Sum X

The description of the problem asks for a Prefix Sum, so there is no confusion. Further optimization can be made by combining the two initial for-loops into one. Code is down below, cheers, ACC.


Read full story
StringBuilder V

One more problem which is simple but leads to TLE if you use String instead of StringBuilder. The entire code below was initially written with String and I got several time-limit exceeded errors. Switching most of the implementation to StringBuilder solved the problem. Code is down below, cheers, ACC.


Read full story

Once concern about Miller-Rabin Primality Test is that it is a probability one. That's true. It can check for primality is O(Log(N)) which is the best that one can get, but probabilistically.The probability of a false positive, however, is (1/4)^k, where k is the number of witnesses in your code. In my implementations I use k=100. Which makes the probability of a false positi...


Read full story