`

HackerRank: Encryption

Posted: 13 February 2019

A simple problem. Not sure why I’m even writing about it but here goes. It was simply executing it and knowing how to use vector and manipulating the grid well. I first coded on paper, and then wrote the code directly into the HackerRank screen. Made a small mistake in the calculation of the row and columns. Instead of enumerating all 4 possible values, I decided to cut it down to 2 and it turns out that was wrong. Fixed that, ran it, and everything passed.

I did do 2 other HackerRank questions today that were really simple (like 2 minutes kind of simple) so I didn’t bother posting them. The first one was about simply taking the average of a vector and the other was on Counting Sort. That was a good refresher. A comparison based sort has a lower bound of n log n but Counting Sort can actually be linear - only if you know the range of values a priori and if the range of values aren’t that big.

Code here.