Hackerrank – Divisible Sum Pairs

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution Create index pairs variations for all indexes that pair is unique – it means when (i, j) exists (j, i) is the same. For each pair calculate the sum of values at corresponding index. If is divisible, count them and […]

Hackerrank – CamelCase

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution There are 2 options To split the string by regular expression”[A-Z]” and then print the length of an array returned from splitting. To iterate over all characters, count the uppercase and print their count + 1 I created solution in: […]

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 – Java Strings Introduction

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

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