Epicor Software Interview Question

coding from hackerrank