Hackerrank – Compare The Triplets

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution Read all ratings and compare it according to the defined conditions: If ai > bi, then Alice is awarded 1 point If ai < bi, then Bob is awarded 1 point If ai = bi, then neither person receives a […]

Hackerrank – The Maximum Subarray

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution Contiguous sum – using Kadane’s algorithm Non-contiguous sum – filter all positive elements from given array and sum them. If this array is empty. Take the greatest element. I created solution in: Scala Java JavaScript Ruby All solutions are also […]

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