Hackerrank – Cut the sticks

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution Until the sticks array is empty: print the length of sticks array sort the array get the minimum value as first element of the array cut the array filtering only values greater than minimum I created solution in: Scala Java […]

Hackerrank – Sherlock and Squares

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution We have to prevent timeout, because there is big upper constraint. For a given numbers a and b we can find out all square numbers with formula:     . There is a special case when a and b are […]

Hackerrank – Modified Kaprekar Numbers

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution Iterate from p to q and check if actual number Kaprekar number (the addition of 2 parts of squared number is equal to actual number) I created solution in: Scala Java JavaScript Ruby All solutions are also available on my […]

Hackerrank – Angry Professor

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution Count all students which come before starting a class (their arrival time is lower or equal to 0). Check if the count of the students is lower than cancellation threshold. I created solution in: Scala Java JavaScript Ruby All solutions […]

Hackerrank – Lisa’s Workbook

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution Take all problems for each chapter. Fill the pages according to rules – each page contains only k problems, or less if chapter ends. Start counting chapter problems from 1. Check if page contains problem with same number. I created […]

Hackerrank – Caesar Cipher

Problem Statement A description of the problem can be found on Hackerrank. Solution Create a function for encrypting which takes a cipher shift as parameter as well. Check if incoming character is letter. If is lower case encrypt it using ascii number: to_char[ascii_of_char – asci_of_a + shift) % 26 + ascii_of_a]. Similar if letter is […]

Hackerrank – Arrays- DS

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

JavaScript

Scala

Ruby

Hackerrank – Valid PAN Format

Problem Statement A description of the problem can be found on Hackerrank. Solution Regex: [A-Z]{5}\d{4}[A-Z] I created solution in: Ruby Java JavaScript Scala All solutions are also available on my GitHub. Ruby

Java

JavaScript

Scala

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