Python/C++ Answer of Leetcode