Hackerrank – Prefix Compression

Problem Statement A description of the problem can be found on Hackerrank. Solution Compare all characters from both string at the same index until they are not equals or we get to the end of one of strings. Equals characters are desired prefix. I created solution in: Scala All solutions are also available on my […]

Hackerrank – Picking Cards

Problem Statement A description of the problem can be found on Hackerrank. Solution Sort the array descending. Take N from the input. For each element e substract N – e. That means that there is only N – e combinations to choose these two cards. After substraction decrement N and select the next element. All […]

Hackerrank – Pangrams

Problem Statement A description of the problem can be found on Hackerrank. Solution Calculate if an input contains 26 distinct characters. I created solution in: Java JavaScript Ruby Scala All solutions are also available on my GitHub. Java

JavaScript

Ruby

Scala

Hackerrank – Pairs

Problem Statement A description of the problem can be found on Hackerrank. Solution Sort the array. Choose one element and check continously every next element after chosen element if their difference is equals to k. If it is greater stop comparisons and choose next element. Note: JavaScript and Ruby solutions use the same algorithm as […]

Hackerrank – Missing Numbers

Problem Statement A description of the problem can be found on Hackerrank. Solution Calculate count of every number in array A and B. Check every number count from B if it is in the array A or its count is lower than the count of the number in the array A. I created solution in: […]

Hackerrank – Minimum Draws

Problem Statement A description of the problem can be found on Hackerrank. Solution Minimum result if always greater then a given count of pairs. I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

Ruby

Hackerrank – Maximizing XOR

Problem Statement A description of the problem can be found on Hackerrank. Solution Create all pairs for all numbers in interval [l, r]. XOR each pair and select maximum. I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

Ruby

Hackerrank – Max Min

Problem Statement A description of the problem can be found on Hackerrank. Solution Sort the given array ascending. Make k parts of the array. Calculate unfairness as difference between last element and first element for all k subarrays. Select the minimum unfairness. Formerly it was called Angry Children. I created solution in: Ruby Java JavaScript […]

Hackerrank – Manasa and Stones

Problem Statement A description of the problem can be found on Hackerrank. Solution The result is set of leaves of a tree in depth n with a stating root 0 and every child is calculated as: parent + a and parent + b. I created solution in: Java JavaScript Scala Ruby All solutions are also […]

Hackerrank – Lonely Integer

Problem Statement A description of the problem can be found on Hackerrank. Solution Find counts of all elements with the same value and print only these that their count is equals to 1. I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

[…]