Hackerrank – Alternating Characters

Problem Statement A description of the problem can be found on Hackerrank. Solution Iterate through all string characters. If actual character i is different then character i-1 then use character i for next comparison. If they are not equal increment a deletion counter. Print the value of the counter. I created solution in: Java JavaScript […]

Hackerrank – Alien Username

Problem Statement A description of the problem can be found on Hackerrank. Solution Regular Expression that validates input username: ^[_\.]\d+[a-zA-Z]*_?$ I created solution in: Java JavaScript Scala Ruby All solutions are also available on my GitHub. Java

JavaScript

Scala

Ruby

Hackerrank – Chocolate Feast

Problem Statement A description of the problem can be found on Hackerrank. Solution Calculate count of chocolates: chocolates = money / price . Count of chocolates is count of wrappers, too. Free chocolates are calculated: divide chocolates with count of chocolates needed for discount add solution of the division to chocolates new wrappers count is: […]

Hackerrank – Cavity Map

Problem Statement A description of the problem can be found on Hackerrank. Solution Filter all matrix indexes that are at the periphery. For all the rest choose one index and compare its value with all neighbours (left, right, up, down). If it is greater than all neighbours, replace it with ‘X’. I created solution in […]

Hackerrank – Service Lane

Problem Statement A description of the problem can be found on Hackerrank. Solution Find minimum in given array from index i to j. I created solution in 4 languages: Scala Java JavaScript Ruby All solutions are also available on my GitHub. Scala

Java

JavaScript

Ruby

Hackerrank – Encryption

Problem Statement A description of the problem can be found on Hackerrank. Solution Calculate a width and height of a required matrix: height = ceil(length(input_string) width = floor(length(input_string) Then create a height x width matrix containing a characters from input_string. Transpose the matrix and print all rows. Node: Instead we can print all columns of […]

Hackerrank – Evaluating e^x

Problem Statement A description of the problem can be found on Hackerrank. Solution

Solution also available on my GitHub.

Hackerrank – Update List

Problem Statement A description of the problem can be found on Hackerrank. Solution

Solution also available on my GitHub.

Hackerrank – List Length

Problem Statement A description of the problem can be found on Hackerrank. Solution

Solution also available on my GitHub.

Hackerrank – Sum of odd elements

Problem Statement A description of the problem can be found on Hackerrank. Solution

Solution also available on my GitHub.