Please turn JavaScript on
Another Casual Coder icon

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:  0.08 / day

Message History

One of my sons asked an interesting question: what number raised to itself equals to 25? In other words, he wanted to find X such that X^X = 25.

I decided to write a simple program (no GAI for a change, just vintage coding) to do that. The key observations here are:

1/ X^X is continuous in the real domain

2/ It grows monotonically 

3/ It grows very fas...


Read full story

Solution here is a simple sliding window approach, the caveat is to cache the mapping number -> list of unique factors which you can use across test cases. Reasonably fast prime factorization is important too, mine isn't the most optimal but fast enough to pass all test cases. Code is down below, cheers, ACC.


Read full story

Another problem whose a solution can be accomplished via Depth-First Search (DFS). Map the tree to a hash table. Calculate the height of the tree separately (also a DFS). Then perform a DFS to calculate the weighted sum. Code is down below, cheers, ACC.


Read full story
Read full story
Post-Order
Read full story