Here is my hacker rank solution using C/C++