Backward thinking + exhaustive search ideas based solution
Intuition\nExhaustive search of all m candiates. And because of the do nothing option, we know if candidate s is valid, s+k is also valid.  Thus we can perform 
# Intuition\nExhaustive search of all `m` candiates. And because of the `do nothing` option, we know if candidate `s` is valid, `s+k` is also valid.  Thus we can perform binary search based validation among all `m` candiates to find the smallest eligible candidate.\n\nThe candiate validation is based on the concept of `backward thinking`. Assuming candiate `s` is valid, replay the sequence of action backward, and validate each step. if nothing violates the constraints in the problem then the calidate is a valid one.\n\n\n# Approach\n\n\n# Complexity\n- Time complexity:\n\nO(mlogm x m)\n\n- Space complexity:\n\nO(n)\n\n# Code\n```\nclass Solution:\n    def earliestSecondToMarkIndices(self, nums: List[int], changeIndices: List[int]) -> int:\n        left,right = 0,len(changeIndices)-1\n        # Find the left most eligible element\n        # stop when left > right: left points to eligible and right points to ineligible elements. \n        while left<= right:\n            mid = (left+right)//2\n            if self.binarySearch(mid,nums,changeIndices):\n                right = mid-1\n            else:\n                left = mid+1\n        if left == len(changeIndices):\n            return -1\n        return left+1\n\n    \n    def binarySearch(self,target,nums,changeIndices) -> bool:\n        visited_idx = set()\n        op_needed = 0\n        for step in range(target,-1,-1):\n            if changeIndices[step] not in visited_idx:\n                visited_idx.add(changeIndices[step])\n                op_needed+=nums[changeIndices[step]-1]\n            else:\n                # op_needed can never be negative, means you can\'t perform the dec for numbers already marked.\n                if op_needed>0:\n                    op_needed-=1\n            if len(visited_idx) == len(nums) and op_needed==0:\n                return True\n        return False\n\n                \n\n\n\n        \n\n```
['Binary Search', 'Python3']