Hackerrank – Compute the Area of a Polygon

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution Create matrices of point pairs as follows

… Calculate the determinat of each matrix: x1 * y2 – x2 * y1 And sum the determinants. In the end divide the sum with 2. Solution based on this. I […]

Hackerrank – Remove Duplicates

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution I created solution in: Scala All solutions are also available on my GitHub. Scala

Hackerrank – Lambda Calculus – Reductions #4

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution I created solution in: Plain Text All solutions are also available on my GitHub. Plain Text

Hackerrank – Lambda Calculus – Reductions #3

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution I created solution in: Plain Text All solutions are also available on my GitHub. Plain Text

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 […]