Hackerrank – Utopian Tree

Problem Statement A description of the problem can be found on Hackerrank. Solution Make a height and initialize its value as 1. For each input number: if it is even double the height if it odd add 1 to height. I created solution in: Java JavaScript Scala Ruby All solutions are also available on my […]

Hackerrank – Two Arrays

Problem Statement A description of the problem can be found on Hackerrank. Solution Sort two arrays. array1 ascending, array2 descending. Add each ith element in both array and compare if their sum is greater or equals than required amount. I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. […]

Hackerrank – The Love-Letter Mystery

Problem Statement A description of the problem can be found on Hackerrank. Solution For an element at index i create sum of differences between an ordinal number of character at index length(s)-i-1 and an ordinal number of the character at index i. I created solution in: Java Ruby JavaScript Scala All solutions are also available […]

Hackerrank – The British and American Style of Spelling

Problem Statement A description of the problem can be found on Hackerrank. Solution For each word in each sentence check if the word contains “ze” (US) or “se” (UK). I created solution in: Scala Ruby JavaScript Java All solutions are also available on my GitHub. Scala

Ruby

JavaScript

Java

Hackerrank – Split the Phone Numbers

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

Java

JavaScript

Ruby

Hackerrank – Sherlock and The Beast

Problem Statement A description of the problem can be found on Hackerrank. Solution Create two number: one of them represents fives_count and the second threes_count. Initialize fives_count as length of the number and threes_count as 0. Check if fives_count is divisible by 3 and threes_count is divisible by 5. Then substract 5 from fives_count and […]

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