Hackerrank – Detecting Valid Latitude and Longitude Pairs

Problem Statement A description of the problem can be found on Hackerrank. Solution My regex for validating longitude and latitude pairs: \([+-]?((90(\.0+)?)|([1-8][0-9](\.[0-9]+)?)|([0-9](\.[0-9]+)?)),\s*[+-]?(((([1-9][0-9])|([0-9]))(\.[0-9]+)?)|(1((80(\.0+)?)|([0-7][0-9](\.[0-9]+)?))))\) All solutions are also available on my GitHub.

Hackerrank – Detect HTML Attributes

Problem Statement A description of the problem can be found on Hackerrank. Solution Parse all tags with attributes. Then parse only tags and attributes. Group attributes by tag name. Sort grouped tags and accordingly attributes. I created solution in: Java Scala All solutions are also available on my GitHub. Java

Scala

Hackerrank – Connecting Towns

Problem Statement A description of the problem can be found on Hackerrank. Solution Count of all routes as multiplication of routes between towns. I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

Ruby

Hackerrank – Computing the GCD

Problem Statement A description of the problem can be found on Hackerrank. Solution I used Euclid’s algorithm for computing Greatest Common Divisor. I created solution in: Scala All solutions are also available on my GitHub. Scala

Hackerrank – Common Child

Problem Statement A description of the problem can be found on Hackerrank. Solution The implementation according to Longest Common Subsequence Problem. Ruby solutions is implemented with the same algorithm as Java solution. One hackerrank test with Ruby solution failed on timeout. I created solution in: Java Ruby All solutions are also available on my GitHub. […]

Hackerrank – Closest Numbers

Problem Statement A description of the problem can be found on Hackerrank. Solution Sort the input array ascending. For element at index i do difference with element at index i+1. Find the minimum difference. Check all elements and find all pair that have this minimum difference. Print found elements ascending. I created solution in: Java […]

Hackerrank – Building a List

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

JavaScript

Ruby

Hackerrank – B’day Gift

Problem Statement A description of the problem can be found on Hackerrank. Solution Sum all elements. The result is sum / 2. I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

Ruby

Hackerrank – Anagram

Problem Statement A description of the problem can be found on Hackerrank. Solution Divide the input string into two halves. Count all common character in the halves. A result is difference between length of the one half and count of the common characters. Different solution deletes common characters from the second half. The result is […]