Leetcodedaybyday - https://www.threads.net/@leetcodedaybyday
IntuitionThe problem asks for the smallest index i for which (i+1) divides nums[i]. Since we are looking for the first such occurrence, it makes sense to start
# Intuition\nThe problem asks for the smallest index `i` for which `(i+1)` divides `nums[i]`. Since we are looking for the first such occurrence, it makes sense to start from the beginning of the array and check each element sequentially. If we find an element that meets the condition, we can stop immediately because that will be the smallest possible index.\n\n# Approach\n1. Iterate through the array from `i = 0` to `i = n-1`.\n2. For each index `i`, check if `(i+1)` divides `nums[i]` evenly, i.e., `nums[i] % (i+1) == 0`.\n3. If the condition is true, return `i` immediately.\n4. If the loop finishes without finding such an index, return `-1`.\n\nThis straightforward method ensures we find the smallest valid index in one pass.\n\n# Complexity\n- **Time Complexity:** \\(O(n)\\) because we need to potentially check all elements once.\n- **Space Complexity:** \\(O(1)\\) since we are only using a few additional variables and not requiring extra space proportional to the input size.\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int smallestEqual(vector<int>& nums) {\n        for(int i = 0; i < nums.size(); i++){\n            if (i % 10 == nums[i]){\n                return i;\n            }\n        }\n        return -1;\n    }\n};\n```\n```python3 []\nclass Solution:\n    def smallestEqual(self, nums: List[int]) -> int:\n        for i in range(len(nums)):\n            if i % 10 == nums[i]:\n                return i\n        return -1\n```
['C++', 'Python3']