hackerrank problem. Finding GEM