[Python] Binary search concise code, beat 85% submission.
\n# Complexity\n- Time complexity:\n Add your time complexity here, e.g. O(n) \nO(nlog(n))\n\n- Space complexity:\n Add your space complexity here, e.g. O(n) \n
\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(nlog(n))$$\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$\n\n# Code\n```\nclass Solution:\n    def earliestSecondToMarkIndices(self, nums: List[int], changeIndices: List[int]) -> int:\n        n = len(nums)\n\n        def helper(end_index) -> bool:\n            if len(set(changeIndices[:end_index+1])) != n:\n                return False\n            num_wildcard = end_index-n+1\n            mark_down = [False] * n\n            take = 0\n            for index in reversed(range(end_index+1)):\n                chosen_index = changeIndices[index]-1\n                if mark_down[chosen_index]:\n                    if take:\n                        take -= 1\n                    num_wildcard -= 1\n                else:\n                    if num_wildcard - take >= nums[chosen_index]:\n                        mark_down[chosen_index] = True\n                        take += nums[chosen_index]\n                    else:\n                        return False\n            return all(mark_down)\n        right = len(changeIndices) - 1\n        if not helper(right):\n            return -1\n        left = 0\n        while left < right:\n            mid = left + (right - left) // 2\n            if helper(mid):\n                right = mid\n            else:\n                left = mid + 1\n        return left + 1\n```
['Python3']