C++ Solution for LeetCode