2nd iteration of leetcode