Finished Gems HackerRank Problem