Leetcode Problem 4 Solution Intermediate