leetcode 8.7