VinBrain Interview Question

HackerRank: Coding Interview - Implement a function