Skip to content

Commit f2a2ded

Browse files
authored
Create smallest-index-with-equal-value.cpp
1 parent 4b21eee commit f2a2ded

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Time: O(n)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
int smallestEqual(vector<int>& nums) {
7+
for (int i = 0; i < size(nums); ++i) {
8+
if (i % 10 == nums[i]) {
9+
return i;
10+
}
11+
}
12+
return -1;
13+
}
14+
};

0 commit comments

Comments
 (0)