Hackerrank – Designer PDF Viewer

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution Find a max height of given characters. Square is max height multiplied with length of the string. I created solution in: Scala Java JavaScript Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

Ruby […]

Hackerrank – Sum vs XOR

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution A mathematical trick. just count total numbers of zero present in binary number of given n, and answer will be the 2 to the power of (total num of zero) Look at the truth table of XOR:

Now look […]

Hackerrank – Flatland Space Stations

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution Fist I sorted the Space station, because they are not always ordered. Then I found out how many cities are between each pair of space stations i and i+1:     Then I calculated the maximum distance for each city […]

Hackerrank – Beautiful Days at the Movies

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution For each number in the given interval between i and j count the numbers with valid given condition. I created solution in: Scala Java JavaScript Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

[…]

Hackerrank – Super Reduced String

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution I created an accumulator with initial value as empty string. I iterated through each character and updated the accumulator if an actual character is equals to last accumulator character, delete this character from the accumulator else append the character to […]

Hackerrank – Jumping on the Clouds

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution I created a pointer for an actual position which starts at index 0. I always tried to jump at position i + 2. If it is not possible because of thundercloud I step at i + 1 position. I do […]

Hackerrank – Beautiful Binary String

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution I replaced all occurences of “010” with an arbitrary placeholder. Then I counted the placeholders. I created solution in: Scala Java JavaScript Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

Ruby

Hackerrank – Circular Array Rotation

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution We rotate the array in circles. That why it is enough to calculate a position after all rotations using modulo. We split the array into two halves at position array_length – calculated_position. We change halves and concat them – the […]

Hackerrank – Jumping on the Clouds: Revisited

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution I jumped for k positions and lowered the energy. If I reached position 0 I printed the remaining enenergy. I created solution in: Scala Java JavaScript Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala […]

Hackerrank – Mars Exploration

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution I divided the whole string into to 3-character parts. Then I checked for each triplet if first character is equal to S, second to O and third to S. And counted the changed letters. I created solution in: Scala Java […]