Hackerrank – Flowers

Problem Statement A description of the problem can be found on Hackerrank. Solution Sort all prices descending. The formula for calculating the flower i in prices: $$total = \sum_{i=0}^{n-1}((i / k + 1) * price_{i})$$ I created solution in: Java JavaScript Ruby Scala All solutions are also available on my GitHub. Java

JavaScript

[…]

Hackerrank – Flipping Bits

Problem Statement A description of the problem can be found on Hackerrank. Solution Define maximum unsigned int in binary as: 11 111 111 111 111 111 111 111 111 111 111. For all input number XOR with maximum and print the output. Aware that some programming languages have signed numbers. It is better to use […]

Hackerrank – Find Point

Problem Statement A description of the problem can be found on Hackerrank. Solution For solution you can check wikipedia page for Point reflection. I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

Ruby

Hackerrank – Find Hackerrank

Problem Statement A description of the problem can be found on Hackerrank. Solution Print “0” if the input matches ^hackerrank$ or ^hackerrank.*hackerrank$ Print “1” if the input matches ^hackerrank.* Print “2” if the input matches .*hackerrank$ else print “-1” I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. […]

Hackerrank – Find Digits

Problem Statement A description of the problem can be found on Hackerrank. Solution Count all digits if the digit is greatest than 0 and if the input is divisible by digit. I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

Ruby

Hackerrank – Find a Substring

Problem Statement A description of the problem can be found on Hackerrank. Solution For all lines cout all ocurrences of this regex pattern: \w+{substring}\w+ I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

Ruby

Hackerrank – Filling Jars

Problem Statement A description of the problem can be found on Hackerrank. Solution sum = (b – a + 1) * no_candies for each operations. Average and floor the sum. I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

Ruby

Hackerrank – Fibonacci Numbers

Problem Statement A description of the problem can be found on Hackerrank. Solution Use the equation for Fibonacci numbers in problem statement: Fibonacci(n) = 0 , n = 1 Fibonacci(n) = 1 , n = 2 Fibonacci(n) = Fibonacci(n-1) + Fibonacci(n-2) , n > 2 I created solution in: Scala All solutions are also available […]

Hackerrank – Even Tree

Problem Statement A description of the problem can be found on Hackerrank. Solution Make a map of a node vs. the nnumber of nodes connected to it. Iterate over the map. If for the ith node, the number of nodes connected is even, then iterate over the nodes list connected to this node. Now for […]

Hackerrank – Equations

Problem Statement A description of the problem can be found on Hackerrank. Solution Make prime number factorization of N!. For help click here or here. I created solution in: Java JavaScript Ruby Scala All solutions are also available on my GitHub. Java

JavaScript

Ruby

Scala