Enclosing Substring Hackerrank Solution