Hackerrank – Maximizing XOR

Problem Statement A description of the problem can be found on Hackerrank. Solution Create all pairs for all numbers in interval [l, r]. XOR each pair and select maximum. I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

Ruby

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 – Manasa and Stones

Problem Statement A description of the problem can be found on Hackerrank. Solution The result is set of leaves of a tree in depth n with a stating root 0 and every child is calculated as: parent + a and parent + b. I created solution in: Java JavaScript Scala Ruby All solutions are also […]

Hackerrank – Lonely Integer

Problem Statement A description of the problem can be found on Hackerrank. Solution Find counts of all elements with the same value and print only these that their count is equals to 1. I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

[…]

Hackerrank – Is Fibo

Problem Statement A description of the problem can be found on Hackerrank. Solution Create Fibonacci sequence and check if the actual Fibonacci number is equals number n. Stop the sequence if actual Fibonacci number is greater then n. I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java […]

Hackerrank – IP Address Validation

Problem Statement A description of the problem can be found on Hackerrank. Solution IP4 regex: \b(((2[0-5][0-5])|(1[0-9][0-9])|(\b[1-9][0-9]\b)|(\b\d\b))\.){3}((2[0-5][0-5])|(1[0-9][0-9])|(\b[1-9][0-9]\b)|(\b\d\b))\b IP6 regex: ([a-f0-9]{1,4}:){7}\b[0-9a-f]{1,4}\b I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

Ruby

Hackerrank – Intro to Tutorial Challenges

Problem Statement A description of the problem can be found on Hackerrank. Solution Check all array elements if one of them is equal to required value. Then print its index to the output. I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

[…]

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

Hackerrank – Ice Cream Parlor

Problem Statement A description of the problem can be found on Hackerrank. Solution For each ith price, check if ith price plus (i+1)th price is equal required amount. I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

Ruby

Hackerrank – Handshake

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

JavaScript

Ruby

Scala