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.24 / day

Message History

This was a very interesting problem in my opinion. It is a classic exercise in simulation, especially related to population growth. The constraints are small enough that you can brute-force and you'll be fine. Some techniques worth mentioning:

1/ Use a hash set for quick verification whether a point is in the generation

2/ Hash using the boundaries - using 7 as a ...


Read full story
Tally the frequency of the vowels. Push that into a pQueue, the caveat is when the frequencies are the same, you need to keep track of the first occurrence of each vowel and do some math to insert into the priority queue with the right order. After that, it is just dequeuing and inserting into the proper places. Use StringBuilder to avoid unnecessary string allocations.Code is d...

Read full story

I think a HashTable (of a HashSet) is a very convenient way to represent a tree. It gives you instant access to any element of the tree if there is a unique id representing each node. The problem (and code) below exemplifies this point. Once the representation is there, performing a Depth-First Search becomes very trivial. Code is down below, cheers, ACC.


Read full story
You can use the .BinarySearch method of List<T>. It works well, there is a bit of a trick that you need to do when the return index is negative (just assign it to its complement, ~index). No need to perform the Binary Search "by hand" anymore. Achieves a good NLogN, fast solution. LC suggests a Tree to be used but this approach (two lists, one for even, one for odd) works ...

Read full story

This is an interesting problem where you do need a priority queue in order to simulate the game (remember to use Max-Color as the priority since the dequeuing is based on smaller priorities first), but the tricky part here is that you cannot enqueue in the main loop while each round simulation is going on otherwise you'll starve lower priority colors. Hence in the middle of t...


Read full story