LeetCode7, but need to think more in order to get bonus!