Leetcode Two Pointer Approach Python Dictionary