C++ Easy Solution || Binary Search
Code\n\nclass Solution {\npublic:\n    bool isPossible(vector<int>& nums, vector<int>& arr, int time) {\n        int count1 = nums.size();\n        long long su
# Code\n```\nclass Solution {\npublic:\n    bool isPossible(vector<int>& nums, vector<int>& arr, int time) {\n        int count1 = nums.size();\n        long long sum = 0;\n        vector<bool> visited(nums.size(), false);\n        for (int i = time - 1; i >= 0; i--) {\n            if (visited[arr[i]-1] == false) {\n                visited[arr[i]-1] = true;\n                sum += nums[arr[i]-1];\n                count1--;\n            } else {\n                if (sum > 0)\n                    sum--;\n            }\n        }\n        return sum == 0 && count1 == 0;\n    }\n\n    int earliestSecondToMarkIndices(vector<int>& nums, vector<int>& changeIndices) {\n        int ans = -1;\n        int low = nums.size();\n        int high = changeIndices.size();\n\n        while (low <= high) {\n            int mid = low + (high - low) / 2;\n            if (isPossible(nums, changeIndices, mid)) {\n                ans = mid;\n                high = mid - 1;\n            } else\n                low = mid + 1;\n        }\n        return ans;\n    }\n};\n```
['Binary Search', 'C++']