Smallest Index With Equal Value || C++ || CPP
The question is straightforward asking you to calculate the minimum index satisfying the given condition : i%10==nums[i]\nJust take one variable for storing the
The question is straightforward asking you to calculate the minimum index satisfying the given condition : i%10==nums[i]\nJust take one variable for storing the minimum index and if you did not get any index satisfying the given condition just simply return -1.\n```\nclass Solution {\npublic:\n    int smallestEqual(vector<int>& nums) {\n        int n = nums.size();\n        int mini = INT_MAX;\n        for(int i=0;i<n;i++)\n        {\n            if(i%10==nums[i])\n            {\n                mini = min(mini,i);\n                break;\n            }\n        }\n        return mini==INT_MAX?-1:mini;\n    }\n};\n```\n\nWithout taking extra variable for storing index :\n```\nclass Solution {\npublic:\n    int smallestEqual(vector<int>& nums) {\n        int n = nums.size();\n        for(int i=0;i<n;i++)\n        {\n            if(i%10==nums[i])\n            {\n                return i;\n            }\n        }\n        return -1;\n    }\n};\n```\n\nFor both codes :\nTime Complexity : O(N)\nSpace Complexity : O(1)\n\n**If you understand the code and approach well, then please upvote this post!!!**
['C', 'C++']