Upper Bound In Leetcode Python