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:

All solutions are also available on my GitHub.

Java

JavaScript

Scala

Ruby