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 – Super Digit

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution Create a recursive function with condition described – see implementation. I created solution in: Scala All solutions are also available on my GitHub. Scala

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 – Compute the Perimeter of a Polygon

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution Calculate a length of a line between each pair of following points p, defined with x and y coordinate: (p0, p1), (p1, p2), …, (pn-1, p0) Length of a line between two points: $$l = \sqrt{{(x_1 – x_2)}^2 + {(y_1 […]

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