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 – 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 – 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 – Insertion Sort – Part 1

Problem Statement A description of the problem can be found on Hackerrank. Solution Assign to auxiliary variable the last element of the array. Iterate from last element to 0th. If an actual element is lower than auxiliary, assign auxiliary to actual index, else switch actual element with last actual. I created solution in: Java JavaScript […]