Solve the populating next right pointer problem in leetcode.