question_slug
stringlengths 3
77
| title
stringlengths 1
183
| slug
stringlengths 12
45
| summary
stringlengths 1
160
⌀ | author
stringlengths 2
30
| certification
stringclasses 2
values | created_at
stringdate 2013-10-25 17:32:12
2025-04-12 09:38:24
| updated_at
stringdate 2013-10-25 17:32:12
2025-04-12 09:38:24
| hit_count
int64 0
10.6M
| has_video
bool 2
classes | content
stringlengths 4
576k
| upvotes
int64 0
11.5k
| downvotes
int64 0
358
| tags
stringlengths 2
193
| comments
int64 0
2.56k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
minimum-moves-to-convert-string | C++, Simple intro to greedy | c-simple-intro-to-greedy-by-abdurrafi_ac-364m | \nint minimumMoves(string s) {\n int cnt=0;\n int i=0;\n while(i<s.size()){\n if(s[i]==\'O\') i++;\n else{\n | abdurrafi_acm | NORMAL | 2021-10-17T07:30:42.697069+00:00 | 2021-10-17T07:30:42.697115+00:00 | 86 | false | ```\nint minimumMoves(string s) {\n int cnt=0;\n int i=0;\n while(i<s.size()){\n if(s[i]==\'O\') i++;\n else{\n cnt++;\n i=i+3;\n }\n }\n return cnt;\n }\n```\n\nAs the problem is very simple - let me explain something here.\nOne can easily test that - the problem requires a \'minimum\' amount - which is an optmization. But why does this optimization does not need dynamic programming?\n\nFor any string **s**, minimum amount for **s[i]** does not depend on the minumim amount for **s[i-1]**. \nFor any additional **s[i+1]** you need to increase the minimum count.\nSee, this is why this optimization does not require dynamic approach.\n | 1 | 0 | [] | 0 |
minimum-moves-to-convert-string | Easy to understand JavaScript solution | easy-to-understand-javascript-solution-b-gt25 | \tvar minimumMoves = function(s) {\n\t\tlet moveIndex = moves = 0;\n\n\t\twhile (moveIndex < s.length) {\n\t\t\tconst findIndex = s.indexOf(\'X\', moveIndex);\n | tzuyi0817 | NORMAL | 2021-10-16T06:57:38.967821+00:00 | 2021-10-16T06:57:38.967855+00:00 | 153 | false | \tvar minimumMoves = function(s) {\n\t\tlet moveIndex = moves = 0;\n\n\t\twhile (moveIndex < s.length) {\n\t\t\tconst findIndex = s.indexOf(\'X\', moveIndex);\n\n\t\t\tif (findIndex > -1) {\n\t\t\t\tmoveIndex = findIndex + 3;\n\t\t\t\tmoves += 1;\n\t\t\t}\n\t\t\telse moveIndex = s.length;\n\t\t}\n\n\t\treturn moves;\n\t}; | 1 | 0 | ['JavaScript'] | 0 |
minimum-moves-to-convert-string | C++ Easy Solution | c-easy-solution-by-saiteja_balla0413-fyss | \nclass Solution {\npublic:\n int minimumMoves(string s) {\n //if you find a \'X\' change the next 3 char to \'O\' and calculate the result\n i | saiteja_balla0413 | NORMAL | 2021-10-13T17:26:15.924406+00:00 | 2021-10-13T17:26:15.924454+00:00 | 90 | false | ```\nclass Solution {\npublic:\n int minimumMoves(string s) {\n //if you find a \'X\' change the next 3 char to \'O\' and calculate the result\n int res=0;\n int n=s.length();\n for(int i=0;i<n;i++)\n {\n if(s[i]==\'X\')\n {\n res++;\n s[i]=\'O\';\n if(i+1<n && s[i+1]==\'X\')\n {\n s[i+1]=\'O\';\n }\n if(i+2<n && s[i+2]==\'X\')\n {\n s[i+2]=\'O\';\n }\n \n }\n }\n return res;\n }\n};\n```\n**Upvote if this helps you :)** | 1 | 0 | ['C'] | 0 |
minimum-moves-to-convert-string | JavaScript Greedy | javascript-greedy-by-lilongxue-5gpi | \n/**\n * @param {string} s\n * @return {number}\n */\nvar minimumMoves = function(s) {\n const len = s.length\n let result = 0\n \n \n for (let | lilongxue | NORMAL | 2021-10-12T03:39:49.694523+00:00 | 2021-10-12T03:39:49.694561+00:00 | 78 | false | ```\n/**\n * @param {string} s\n * @return {number}\n */\nvar minimumMoves = function(s) {\n const len = s.length\n let result = 0\n \n \n for (let i = 0; i < len; ) {\n const ch = s[i]\n if (ch === \'O\') i++\n else {\n result++\n i += 3\n }\n }\n \n \n return result\n};\n``` | 1 | 0 | [] | 0 |
minimum-moves-to-convert-string | Python simple solution better than 97% | python-simple-solution-better-than-97-by-zjpl | ```\nclass Solution(object):\n def minimumMoves(self, s):\n """\n :type s: str\n :rtype: int\n """\n\t\t ans, l = 0, 0\n w | avigupta10 | NORMAL | 2021-10-09T13:30:01.403037+00:00 | 2021-10-09T13:30:01.403079+00:00 | 209 | false | ```\nclass Solution(object):\n def minimumMoves(self, s):\n """\n :type s: str\n :rtype: int\n """\n\t\t ans, l = 0, 0\n while l < len(s):\n if s[l] == \'X\':\n l+=3\n ans +=1\n else:\n l+=1\n return ans | 1 | 0 | ['Python3'] | 0 |
minimum-moves-to-convert-string | simple C++ | simple-c-by-ujjwal2001kant-e6r1 | ```\nclass Solution {\npublic:\n int minimumMoves(string s) {\n int n=s.size();\n \n int ans=0;\n for(int i=0; i<n;)\n {\n | ujjwal2001kant | NORMAL | 2021-10-05T15:27:05.177197+00:00 | 2021-10-07T10:10:29.333954+00:00 | 54 | false | ```\nclass Solution {\npublic:\n int minimumMoves(string s) {\n int n=s.size();\n \n int ans=0;\n for(int i=0; i<n;)\n {\n if(s[i]==\'X\')\n ans++,i=i+3; //for this X we are using 1 move and by doing that we can move 3 steps without any checks\n else\n i++; \n }\n \n return ans;\n }\n}; | 1 | 0 | [] | 0 |
minimum-moves-to-convert-string | Intuitive | intuitive-by-thinkinoriginal-gxva | \nclass Solution {\npublic:\n int minimumMoves(string s) {\n int len = s.size();\n int res = 0;\n \n for (int i = 0; i < len; i++ | thinkinoriginal | NORMAL | 2021-10-05T07:22:25.882084+00:00 | 2021-10-05T07:22:25.882116+00:00 | 66 | false | ```\nclass Solution {\npublic:\n int minimumMoves(string s) {\n int len = s.size();\n int res = 0;\n \n for (int i = 0; i < len; i++) {\n if (s[i] == \'X\') {\n res++;\n i += 2;\n }\n }\n \n return res;\n \n }\n};\n``` | 1 | 0 | ['C++'] | 0 |
minimum-moves-to-convert-string | a few solutions | a-few-solutions-by-claytonjwong-sxbi | Peform a linear scan of the input array A. For each X seen, skip past it and the next 2 indices (inclusive, so 1 + 2 = 3) and increment the count cnt to be ret | claytonjwong | NORMAL | 2021-10-04T23:56:40.639927+00:00 | 2021-10-04T23:56:40.639959+00:00 | 59 | false | Peform a linear scan of the input array `A`. For each `X` seen, skip past it and the next 2 indices (inclusive, so 1 + 2 = 3) and increment the count `cnt` to be returned.\n\n---\n\n*Kotlin*\n```\nclass Solution {\n fun minimumMoves(s: String): Int {\n var cnt = 0\n var N = s.length\n var i = 0\n while (i < N) {\n if (s[i] == \'X\') {\n i += 3; cnt += 1\n } else {\n ++i\n }\n } \n return cnt\n }\n}\n```\n\n*Javascript*\n```\nlet minimumMoves = (s, cnt = 0) => {\n let N = s.length,\n i = 0;\n while (i < N) {\n if (s[i] == \'X\')\n i += 3, ++cnt;\n else\n ++i;\n }\n return cnt;\n};\n```\n\n*Python3*\n```\nclass Solution:\n def minimumMoves(self, s: str, cnt = 0) -> int:\n N = len(s)\n i = 0\n while i < N:\n if s[i] == \'X\':\n i += 3; cnt += 1\n else:\n i += 1\n return cnt\n```\n\n*C++*\n```\nclass Solution {\npublic:\n int minimumMoves(string s, int cnt = 0) {\n int N = s.size(),\n i = 0;\n while (i < N) {\n if (s[i] == \'X\')\n i += 3, ++cnt;\n else\n ++i;\n }\n return cnt;\n }\n};\n``` | 1 | 0 | [] | 1 |
minimum-moves-to-convert-string | (C++) 2027. Minimum Moves to Convert String | c-2027-minimum-moves-to-convert-string-b-9aen | \n\nclass Solution {\npublic:\n int minimumMoves(string s) {\n int ans = 0; \n for (int i = 0; i < s.size(); ++i) \n if (s[i] == \'X | qeetcode | NORMAL | 2021-10-03T23:06:57.890563+00:00 | 2021-10-03T23:07:26.902340+00:00 | 112 | false | \n```\nclass Solution {\npublic:\n int minimumMoves(string s) {\n int ans = 0; \n for (int i = 0; i < s.size(); ++i) \n if (s[i] == \'X\') \n ++ans, i += 2; \n return ans; \n }\n};\n``` | 1 | 0 | ['C'] | 0 |
minimum-moves-to-convert-string | O(n) - easy | on-easy-by-shreyansh94-vypt | \nclass Solution {\n public int minimumMoves(String s) {\n int m = 0;\n for(int i = 0; i < s.length(); ++i) if(s.charAt(i) == \'X\') { i+=2; m+ | shreyansh94 | NORMAL | 2021-10-03T22:50:59.846668+00:00 | 2021-10-03T22:50:59.846710+00:00 | 106 | false | ```\nclass Solution {\n public int minimumMoves(String s) {\n int m = 0;\n for(int i = 0; i < s.length(); ++i) if(s.charAt(i) == \'X\') { i+=2; m++;}\n return m;\n }\n}\n``` | 1 | 0 | ['Java'] | 0 |
minimum-moves-to-convert-string | C++| Easy to Understand | 0ms Runtime | Small Code |100% faster | O(n) approach | c-easy-to-understand-0ms-runtime-small-c-bzo0 | DO Like my solution , if you Find my Post Helpfull !!!\n\nclass Solution {\npublic:\n int minimumMoves(string s) {\n int count=0;// answer will be sto | ashishkataria002 | NORMAL | 2021-10-03T12:34:55.672319+00:00 | 2021-10-03T12:35:34.487720+00:00 | 57 | false | DO Like my solution , if you Find my Post Helpfull !!!\n```\nclass Solution {\npublic:\n int minimumMoves(string s) {\n int count=0;// answer will be stored in this variable\n for(int i=0;i<s.length();i++){\n if(s[i]==\'X\'){// if substring of size 3 starts with \'X\' -->++count and increment by 2\n ++count;\n i+=2;\n }\n }\n return count;\n \n }\n};\n```\n\n\n | 1 | 0 | ['Greedy', 'C'] | 0 |
minimum-moves-to-convert-string | [JAVA] O(n) , 100% efficient solution | java-on-100-efficient-solution-by-gaurav-0uwk | ```\nclass Solution {\n public int minimumMoves(String s) {\n int moves = 0;\n int i = 0;\n \n char[] arr = s.toCharArray();\n | gaurav_915 | NORMAL | 2021-10-03T12:34:45.998225+00:00 | 2021-10-03T12:34:45.998269+00:00 | 28 | false | ```\nclass Solution {\n public int minimumMoves(String s) {\n int moves = 0;\n int i = 0;\n \n char[] arr = s.toCharArray();\n \n while(i < arr.length) {\n if(arr[i] == \'O\') {\n i++;\n continue;\n }\n \n i+=3;\n moves++;\n }\n \n return moves;\n }\n} | 1 | 0 | [] | 0 |
minimum-moves-to-convert-string | approach with single for loop | approach-with-single-for-loop-by-michelu-a9oa | scan for X the skip forward by size of the move (3)\n\n\n```\n int minimumMoves(const string& s) const {\n int res{};\n \n for (size_t p | michelusa | NORMAL | 2021-10-03T12:30:28.507218+00:00 | 2021-10-03T12:30:28.512883+00:00 | 22 | false | * scan for X the skip forward by size of the move (3)\n\n\n```\n int minimumMoves(const string& s) const {\n int res{};\n \n for (size_t pos = 0; pos < s.size(); pos += (s[pos] == \'X\') ? 3 : 1) {\n res += (s[pos] == \'X\') ? 1 : 0;\n \n }\n \n return res;\n } | 1 | 0 | ['C'] | 0 |
minimum-moves-to-convert-string | as simple as possible | as-simple-as-possible-by-aksh-99-7w8f | ```\nclass Solution {\npublic:\n int minimumMoves(string s) {\n int cnt=0;\n int n=s.size();\n int i=0;\n while(i<n){\n | aksh-99 | NORMAL | 2021-10-03T07:28:10.118375+00:00 | 2021-10-03T07:28:10.118412+00:00 | 135 | false | ```\nclass Solution {\npublic:\n int minimumMoves(string s) {\n int cnt=0;\n int n=s.size();\n int i=0;\n while(i<n){\n if(s[i]==\'O\'){\n i++;\n }else{\n cnt++;i+=3;\n }\n }\n return cnt;\n }\n}; | 1 | 0 | [] | 1 |
minimum-moves-to-convert-string | c++(0ms 100%) simple, easy, small | c0ms-100-simple-easy-small-by-zx007pi-f28l | Runtime: 0 ms, faster than 100.00% of C++ online submissions for Minimum Moves to Convert String.\nMemory Usage: 6.5 MB, less than 80.00% of C++ online submissi | zx007pi | NORMAL | 2021-10-03T06:22:04.464929+00:00 | 2021-10-03T06:22:04.464970+00:00 | 104 | false | Runtime: 0 ms, faster than 100.00% of C++ online submissions for Minimum Moves to Convert String.\nMemory Usage: 6.5 MB, less than 80.00% of C++ online submissions for Minimum Moves to Convert String.\n```\nclass Solution {\npublic:\n int minimumMoves(string s) {\n int i = 0, ans = 0, n = s.size();\n \n while(i < s.size())\n if(s[i] == \'O\') i++;\n else i += 3, ans++; \n \n return ans;\n }\n};\n``` | 1 | 0 | ['C', 'C++'] | 0 |
minimum-moves-to-convert-string | javascript greedy direct way 68ms | javascript-greedy-direct-way-68ms-by-hen-uc0w | \nconst minimumMoves = (s) => {\n let res = 0, n = s.length;\n for (let i = 0; i < n;) {\n if (s[i] == \'X\') { // if find X, we can do max 3 chang | henrychen222 | NORMAL | 2021-10-03T05:35:55.590852+00:00 | 2021-10-03T05:38:28.938735+00:00 | 143 | false | ```\nconst minimumMoves = (s) => {\n let res = 0, n = s.length;\n for (let i = 0; i < n;) {\n if (s[i] == \'X\') { // if find X, we can do max 3 change from "X" -> "O", no matter it is "X" or "O" in i+1 and i+2, will count 1 operation\n i += 3;\n res++;\n } else {\n i++;\n }\n }\n return res;\n};\n``` | 1 | 0 | ['Greedy', 'JavaScript'] | 0 |
minimum-moves-to-convert-string | Can some explain why the o/p for "OXOX" is 1 when but I think it should be 2 | can-some-explain-why-the-op-for-oxox-is-ou7k6 | Here is my implementation which giving output as 2 but the Leetcode compiler is expecting 1\n\n\npublic static int minimumMoves(String s) {\n\n\t\tif (s.indexOf | sangu_7 | NORMAL | 2021-10-03T04:15:01.546570+00:00 | 2021-10-03T04:15:01.546606+00:00 | 178 | false | Here is my implementation which giving output as 2 but the Leetcode compiler is expecting 1\n\n```\npublic static int minimumMoves(String s) {\n\n\t\tif (s.indexOf(\'X\') < 0) {\n\t\t\treturn 0;\n\t\t}\n\t\tchar[] arr = s.toCharArray();\n\t\tint n = arr.length;\n\t\tint count = 0;\n\t\tint start = 0;\n\t\tint end = 0;\n\t\twhile (start < n) {\n\t\t\tif ((start + 3) > arr.length - 1) {\n\t\t\t\tend = n - 1;\n\t\t\t} else {\n\t\t\t\tend = (start + 3) - 1;\n\t\t\t}\n\t\t\tboolean flip = false;\n\t\t\tint ind = start;\n\t\t\twhile (ind <= end) {\n\t\t\t\tif (arr[ind] == \'X\') {\n\t\t\t\t\tarr[ind] = \'O\';\n\t\t\t\t\tflip = true;\n\t\t\t\t}\n\t\t\t\tind++;\n\t\t\t}\n\t\t\tcount += flip ? 1 : 0;\n\t\t\tstart += 1;\n\t\t}\n\n\t\treturn count;\n\n\t}\n```\n\nExplaination : "0X0X"\nfirst 3 characters -> "000" -> s becoms -> "000X" -> res - 1\nnext 3 characters -> "00X" -> s becoms -> "0000" -> res - 2,\n\nis my understanding clear? | 1 | 1 | [] | 2 |
minimum-moves-to-convert-string | Java O(n) | java-on-by-vikrant_pc-a4jf | \npublic int minimumMoves(String s) {\n\tint result = 0, firstXIndex = -1;\n\tfor(int i=0;i<s.length();i++)\n\t\tif(s.charAt(i) == \'X\' && firstXIndex == -1)\n | vikrant_pc | NORMAL | 2021-10-03T04:03:42.183808+00:00 | 2021-10-03T04:03:42.183854+00:00 | 173 | false | ```\npublic int minimumMoves(String s) {\n\tint result = 0, firstXIndex = -1;\n\tfor(int i=0;i<s.length();i++)\n\t\tif(s.charAt(i) == \'X\' && firstXIndex == -1)\n\t\t\tfirstXIndex = i;\n\t\telse if(i - firstXIndex == 2 && i>1) {\n\t\t\tresult++; // Convert\n\t\t\tfirstXIndex = -1;\n\t\t}\n\treturn firstXIndex != -1 ? result + 1 : result;\n}\n``` | 1 | 1 | [] | 0 |
smallest-index-with-equal-value | Not sure what is the point | not-sure-what-is-the-point-by-votrubac-11jb | Python 3\nPerhaps to solve it with a one-liner?\n\npython\nclass Solution:\n smallestEqual = lambda self, nums: next((i for i, n in enumerate(nums) if n == i | votrubac | NORMAL | 2021-10-31T04:03:17.064178+00:00 | 2022-01-25T17:30:15.597359+00:00 | 4,149 | false | **Python 3**\nPerhaps to solve it with a one-liner?\n\n```python\nclass Solution:\n smallestEqual = lambda self, nums: next((i for i, n in enumerate(nums) if n == i % 10), -1) \n```\n**C++**\n```cpp\nint smallestEqual(vector<int>& nums) {\n for (int i = 0; i < nums.size(); ++i)\n if (nums[i] == i % 10)\n return i;\n return -1;\n}\n``` | 38 | 5 | [] | 10 |
smallest-index-with-equal-value | [Python3] 1-line | python3-1-line-by-ye15-5luy | Please check out this commit for my solutions of weekly 265. \n\nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n return next((i f | ye15 | NORMAL | 2021-10-31T04:02:10.694950+00:00 | 2021-11-01T17:14:31.443756+00:00 | 1,327 | false | Please check out this [commit](https://github.com/gaosanyong/leetcode/commit/4001168494179e85482f91afbf0cd66b908544f3) for my solutions of weekly 265. \n```\nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n return next((i for i, x in enumerate(nums) if i%10 == x), -1)\n``` | 16 | 2 | ['Python3'] | 0 |
smallest-index-with-equal-value | Python simple and short solution | python-simple-and-short-solution-by-tova-bu4v | Python :\n\n\ndef smallestEqual(self, nums: List[int]) -> int:\n\tfor idx, n in enumerate(nums):\n\t\tif idx % 10 == n:\n\t\t\treturn idx\n\treturn -1 \n\n\nLik | TovAm | NORMAL | 2021-11-09T11:00:48.743489+00:00 | 2021-11-09T11:12:07.807232+00:00 | 1,128 | false | **Python :**\n\n```\ndef smallestEqual(self, nums: List[int]) -> int:\n\tfor idx, n in enumerate(nums):\n\t\tif idx % 10 == n:\n\t\t\treturn idx\n\treturn -1 \n```\n\n**Like it ? please upvote !** | 12 | 1 | ['Python', 'Python3'] | 2 |
smallest-index-with-equal-value | Java solution without using mod | java-solution-without-using-mod-by-climb-wt61 | Perhaps the point is to ask the follow up question to implement it without using mod.\n10*d1 + d2 is all possible indices which can only go up to 99 (constraint | climberig | NORMAL | 2021-10-31T06:50:27.182522+00:00 | 2021-11-03T01:50:39.257865+00:00 | 1,544 | false | Perhaps the point is to ask the follow up question to implement it without using mod.\n```10*d1 + d2``` is all possible indices which can only go up to 99 (constraints). ```(10*d1 + d2)%10 = d2```\n```java\n public int smallestEqual(int[] a) {\n for (int d1 = 0; d1 <= 9; d1++)\n for (int d2 = 0; d2 <= 9 && 10 * d1 + d2 < a.length; d2++)\n if (d2 == a[d1 * 10 + d2])\n return d1 * 10 + d2;\n return -1;\n } | 10 | 1 | [] | 4 |
smallest-index-with-equal-value | Easiest Javascript solution - O(n) | easiest-javascript-solution-on-by-rituja-la2j | \n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar smallestEqual = function(nums) {\n return nums.findIndex((n, i) => i % 10 === n)\n};\n | ritujadixit | NORMAL | 2021-12-17T06:26:43.140539+00:00 | 2021-12-17T06:26:43.140594+00:00 | 508 | false | ```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar smallestEqual = function(nums) {\n return nums.findIndex((n, i) => i % 10 === n)\n};\n``` | 8 | 0 | ['JavaScript'] | 1 |
smallest-index-with-equal-value | C++ Simple 3-Line Solution | c-simple-3-line-solution-by-yehudisk-dvd3 | \nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int i = 0;\n while (i < nums.size() && i % 10 != nums[i]) i++;\n | yehudisk | NORMAL | 2021-10-31T09:51:41.050229+00:00 | 2021-10-31T09:51:41.050269+00:00 | 1,008 | false | ```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int i = 0;\n while (i < nums.size() && i % 10 != nums[i]) i++;\n return i >= nums.size() ? -1 : i;\n }\n};\n```\n**Like it? please upvote!** | 8 | 0 | ['C'] | 0 |
smallest-index-with-equal-value | Python3|| Beats 98.62% || Beginner simple solution | python3-beats-9862-beginner-simple-solut-msf8 | \n\n\n# Code\n\nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n for i in range(len(nums)):\n if i%10 == nums[i]:\n | Kalyan_2003 | NORMAL | 2023-03-03T10:48:28.046159+00:00 | 2023-03-03T10:48:28.046201+00:00 | 484 | false | \n\n\n# Code\n```\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 break\n return -1\n```\n\n | 5 | 0 | ['Array', 'Python3'] | 2 |
smallest-index-with-equal-value | [JAVA] straight forward solution | java-straight-forward-solution-by-jugant-8gg2 | \n\n# Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n | Jugantar2020 | NORMAL | 2022-11-02T07:33:07.762188+00:00 | 2022-11-02T07:33:07.762228+00:00 | 494 | false | \n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int smallestEqual(int[] nums) {\n for(int i = 0; i < nums.length; i ++) {\n if(i % 10 == nums[i]) { \n return i;\n \n }\n }\n return - 1; \n }\n}\n```\n# PLEASE UPVOTE IF IT WAS HELPFULL | 5 | 0 | ['Java'] | 0 |
smallest-index-with-equal-value | [C++] Simple Solutions Explained, 100% Time (0ms), ~80% Space (22MB) | c-simple-solutions-explained-100-time-0m-65jq | I am not sure if there is a single problem easier than this on the whole suite of 2000+ problems published so far, as this one is literally just about following | Ajna2 | NORMAL | 2021-11-07T21:32:38.639710+00:00 | 2021-11-07T21:32:38.639744+00:00 | 714 | false | I am not sure if there is a single problem easier than this on the whole suite of 2000+ problems published so far, as this one is literally just about following instructions, but, hey, whatever.\n\nStill worth giving it a shot and in an interview you might still gain some points in the eyes of your interviewer if you mention that since modulo operations are rather expensive, we will not bother with them when the currently parsed argument is `> 9`.\n\nOther than that, we will have a main loop to parse the whole `nums`, `return` the first index `i` matching our condition (if any) and otherwise, exiting the loop, `return` `-1`.\n\nThe code:\n\n```cpp\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for (int i = 0, len = nums.size(), n; i < len; i++) {\n n = nums[i];\n if (n < 10 && n == i % 10) return i;\n }\n return -1;\n }\n};\n```\n\nEven better if we rule out the modulo operation altogether:\n\n```cpp\nconstexpr int mods[101] = {\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9\n};\n\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for (int i = 0, len = nums.size(), n; i < len; i++) {\n n = nums[i];\n if (n < 10 && n == mods[i]) return i;\n }\n return -1;\n }\n};\n```\n\nIn constant space, maybe? Hell, yeah - this one gave me `0` ms \uD83D\uDC4D :\n\n```cpp\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for (int i = 0, j = 0, len = nums.size(), n; i < len; i++, j++) {\n n = nums[i];\n if (j == 10) j -= 10;\n if (n < 10 && n == j) return i;\n }\n return -1;\n }\n};\n``` | 5 | 0 | ['Math', 'C', 'C++'] | 2 |
smallest-index-with-equal-value | Python 1 line - 99% speed 95% memory usage | python-1-line-99-speed-95-memory-usage-b-c3j1 | \n\nMake use of recursion to loop over nums array. Return -1 if i exceeds the last index of nums\n```\nclass Solution(object):\n def smallestEqual(self, nums | SmittyWerbenjagermanjensen | NORMAL | 2021-11-04T01:59:58.898678+00:00 | 2021-11-04T02:02:10.435962+00:00 | 729 | false | \n\nMake use of recursion to loop over ```nums``` array. Return ```-1``` if ```i``` exceeds the last index of ```nums```\n```\nclass Solution(object):\n def smallestEqual(self, nums, i=0):\n return -1 if i == len(nums) else ( i if i%10 == nums[i] else self.smallestEqual(nums, i+1) ) | 5 | 0 | ['Recursion', 'Python', 'Python3'] | 1 |
smallest-index-with-equal-value | ✅ Short & Easy | c++ | java | python | short-easy-c-java-python-by-rajat_gupta-b7ye | C++\n\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for(int i=0;i<nums.size();i++){\n if(i%10 == nums[i]) return i; | rajat_gupta_ | NORMAL | 2021-10-31T04:01:04.199444+00:00 | 2021-10-31T04:23:02.245444+00:00 | 390 | false | **C++**\n```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for(int i=0;i<nums.size();i++){\n if(i%10 == nums[i]) return i;\n }\n return -1;\n }\n};\n```\n**Java**\n```\nclass Solution {\n public int smallestEqual(int[] nums) {\n for(int i=0;i<nums.length;i++){\n if(nums[i]==i%10) return i;\n }\n return -1;\n }\n}\n```\n**Python**\n```\nclass Solution:\n\tdef smallestEqual(self, nums: List[int]) -> int:\n\t\tfor i, num in enumerate(nums):\n\t\t\tif i % 10 == num:\n\t\t\t\treturn i\n\t\treturn -1\n\n```\nFeel free to ask any question in the comment section.\n**I hope that you\'ve found the solution useful.**\nIn that case, **please do upvote and encourage me** to on my quest to document all leetcode problems\uD83D\uDE03\nHappy Coding :)\n | 5 | 4 | ['C', 'Python', 'C++', 'Java'] | 0 |
smallest-index-with-equal-value | 💢☠💫Easiest👾Faster✅💯 Lesser🧠 🎯 C++✅Python3🐍✅Java✅C✅Python🐍✅C#✅💥🔥💫Explained☠💥🔥 Beats 💯 | easiestfaster-lesser-cpython3javacpython-lfab | Intuition\n\n\nC++ []\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for(int i = 0; i < nums.size(); ++i){\n if(i % | Edwards310 | NORMAL | 2024-07-20T17:19:06.963398+00:00 | 2024-07-20T17:19:06.963425+00:00 | 243 | false | # Intuition\n\n\n```C++ []\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 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```\n```C# []\npublic class Solution {\n public int SmallestEqual(int[] nums) {\n for(int i = 0; i < nums.Length; ++i){\n if(i % 10 == nums[i])\n return i;\n }\n return -1;\n }\n}\n```\n```Java []\nclass Solution {\n public int smallestEqual(int[] nums) {\n int i = 0;\n int n = nums.length;\n while(i < n){\n if(i % 10 == nums[i])\n return i;\n i++;\n }\n return -1;\n }\n}\n```\n```python []\nclass Solution(object):\n def smallestEqual(self, nums):\n """\n :type nums: List[int]\n :rtype: int\n """\n for u in range(len(nums)):\n if u % 10 == nums[u]:\n return u\n return -1\n```\n```C []\nint smallestEqual(int* nums, int numsSize) {\n for(int i = 0; i < numsSize; ++i){\n if(i % 10 == nums[i])\n return i;\n }\n return -1;\n}\n```\n\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n O(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n O(1)\n# Code\n```\nclass Solution {\n public int smallestEqual(int[] nums) {\n int i = 0;\n int n = nums.length;\n while(i < n){\n if(i % 10 == nums[i])\n return i;\n i++;\n }\n return -1;\n }\n}\n```\n\n | 4 | 0 | ['Array', 'Math', 'C', 'Python', 'C++', 'Java', 'Python3', 'C#'] | 0 |
smallest-index-with-equal-value | Java || 1000% beats || beginner friendly || | java-1000-beats-beginner-friendly-by-sau-4u66 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | saurabh_kumar1 | NORMAL | 2023-10-13T20:39:25.062967+00:00 | 2023-10-13T20:39:25.062991+00:00 | 158 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:0(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:0(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int smallestEqual(int[] nums) {\n for(int i=0; i<nums.length; i++){\n if(i%10==nums[i]) return i;\n }\n return -1;\n }\n}\n``` | 4 | 0 | ['Java'] | 0 |
smallest-index-with-equal-value | Smallest Index With Equal Value solution in short👍 | smallest-index-with-equal-value-solution-61uk | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | ASHWANI_1404 | NORMAL | 2022-11-06T11:27:07.057857+00:00 | 2022-11-06T11:27:07.057882+00:00 | 275 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nint smallestEqual(int* nums, int numsSize){\n for(int i=0;i<numsSize;i++)\n {\n if(i%10==nums[i])\n {\n return i;\n }\n }\n return -1;\n\n\n}\n``` | 4 | 0 | ['C'] | 0 |
smallest-index-with-equal-value | JavaScript solutions (2), 100%/39%, 68ms, also a 1-liner | javascript-solutions-2-10039-68ms-also-a-20k6 | Answer 1 - 100%/39%, 68ms:\n- Create a for loop that iterates through the nums array.\n- Inside the loop use an if statement to check if nums[i] % 10 === i % 1 | kfig21 | NORMAL | 2021-11-02T04:26:38.495090+00:00 | 2021-11-02T05:28:41.942995+00:00 | 361 | false | **Answer 1 - 100%/39%, 68ms:**\n- Create a for loop that iterates through the `nums` array.\n- Inside the loop use an if statement to check if `nums[i] % 10 === i % 10`. If true, return `i`.\n\t- example\n\t\t- nums = [ 3, 3, 5, 1, 8, 2, 3, 0, 1, 2, 3, 7, 6, 9, **4**, 1 ]\n\t\t- when `i = 14`, the loop will compute if `4 % 10 === 14 % 10` which is true as both sides will equal 4.\n\t\t- return `i`, which is 14.\n- If the loop doesn\'t return a value, return -1.\n\n**Solution:**\n\n```\nvar smallestEqual = function(nums) {\n for(let i = 0; i < nums.length; i++){ if (nums[i] % 10 === i % 10) { return i } }\n return -1\n};\n```\n\n---\n**One-Liner - 85%/39%, 88ms:**\n\n- Start by mapping to a new array. If `nums[i] % 10 === i % 10` map `i`, else map 100\n\t- `...nums.map((x, i) => (nums[i] % 10 === i % 10) ? i : 100 )`\n- Find the min of the newly mapped array with Math.min()\n\t- `Math.min( ...nums.map((x, i) => (nums[i] % 10 === i % 10) ? i : 100 )`\n- Place the value into an array and filter for it being less than 100. If the min value from the previous step is 100 that means none of the indexed numbers qualified for the result, filtering out 100 will leave us with an empty array.\n\t- `[ Math.min( ...nums.map((x, i) => (nums[i] % 10 === i % 10) ? i : 100 ) ) ].filter(x => x < 100)`\n- Inside a Math.max() function spread the new array and incude a -1. If there was an indexed number in the array that will be the answer returned, if not then we will return -1.\n\t- `Math.max( ...[ Math.min( ...nums.map((x, i) => (nums[i] % 10 === i % 10) ? i : 100 ) ) ].filter(x => x < 100) , -1)`\n\n```\nvar smallestEqual = (nums) => Math.max( ...[ Math.min( ...nums.map((x, i) => (nums[i] % 10 === i % 10) ? i : 100 ) ) ].filter(x => x < 100) , -1);\n``` | 4 | 1 | ['JavaScript'] | 1 |
smallest-index-with-equal-value | 'Smallest || fastest ||| Easy Solution | smallest-fastest-easy-solution-by-iamcod-d9h9 | \nclass Solution {\n\n public int smallestEqual(int[] nums) {\n for(int i=0;i<nums.length;i++){\n if(i%10==nums[i]) return i;\n }\n | IAmCoderrr | NORMAL | 2021-10-31T04:12:01.729818+00:00 | 2021-10-31T04:12:01.729845+00:00 | 295 | false | `\nclass Solution {\n\n public int smallestEqual(int[] nums) {\n for(int i=0;i<nums.length;i++){\n if(i%10==nums[i]) return i;\n }\n return -1;\n }\n}` | 4 | 2 | ['Java'] | 0 |
smallest-index-with-equal-value | Simple Solution | Beginner Friendly | Easy Approach with Explanation✅ | simple-solution-beginner-friendly-easy-a-iwhb | Intuition\n Describe your first thoughts on how to solve this problem. \n- The task is to find the smallest index where the condition i % 10 == nums[i] holds tr | Jithinp96 | NORMAL | 2024-11-27T14:23:18.653627+00:00 | 2024-11-27T14:23:18.653655+00:00 | 118 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- The task is to find the smallest index where the condition i % 10 == nums[i] holds true.\n- We need to check each index i and compare the value at that index with i % 10. If a match is found, return the index.\n- If no such index exists, return -1. Since the problem asks for the smallest such index, we can return the first one we find.\n\n# Approach\n1. Iterate over the array `nums` and check if the current index `i` satisfies the condition `i % 10 == nums[i]`.\n2. If a match is found, return the index `i` immediately.\n3. If no match is found after checking all indices, return -1.\n\n# Code\n```javascript []\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar smallestEqual = function(nums) {\n for(let i=0;i<nums.length;i++){\n if(i%10==nums[i]) {\n return i\n }\n }\n return -1\n};\n```\n\n```typescript []\nfunction smallestEqual(nums: number[]): number {\n for (let i = 0; i < nums.length; i++) {\n if (i % 10 === nums[i]) {\n return i;\n }\n }\n return -1;\n}; | 3 | 0 | ['TypeScript', 'JavaScript'] | 0 |
smallest-index-with-equal-value | simple one PYTHON | simple-one-python-by-justingeorge-mcjl | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | justingeorge | NORMAL | 2024-03-25T09:40:02.160338+00:00 | 2024-03-25T09:40:02.160374+00:00 | 77 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n\n for i in range(len(nums)):\n if i % 10 == nums[i]:\n return i\n else:\n return -1\n \n``` | 3 | 0 | ['Python3'] | 0 |
smallest-index-with-equal-value | 1 line solution 🔥100% Faster Code 🔥 Beginner Friendly 🔥 | 1-line-solution-100-faster-code-beginner-uajs | Please UPVOTE if helps.\n\n# Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space comple | diyordev | NORMAL | 2023-12-08T17:38:19.816372+00:00 | 2023-12-08T17:38:19.816404+00:00 | 73 | false | # Please UPVOTE if helps.\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int smallestEqual(int[] nums) {\n for (int i = 0; i < nums.length; i++)if (i % 10 == nums[i]) return i;\n return -1;\n }\n}\n``` | 3 | 0 | ['Java'] | 0 |
smallest-index-with-equal-value | C++ 100% Fast Run Time Solution ( Easy to Understand ) | c-100-fast-run-time-solution-easy-to-und-rwea | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | abhirajpratapsingh | NORMAL | 2023-10-02T17:04:52.597070+00:00 | 2023-10-02T17:04:52.597102+00:00 | 21 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) \n {\n vector<int>v;\n for(int i=0;i<nums.size();i++)\n {\n if(i%10==nums[i])\n return i;\n }\n return -1;\n }\n};\n``` | 3 | 0 | ['C++'] | 0 |
smallest-index-with-equal-value | [Accepted] Swift | accepted-swift-by-vasilisiniak-lbrd | \nclass Solution {\n func smallestEqual(_ nums: [Int]) -> Int {\n nums.indices.first { $0 % 10 == nums[$0] } ?? -1\n }\n}\n | vasilisiniak | NORMAL | 2022-12-22T08:32:35.320324+00:00 | 2022-12-22T08:32:35.320374+00:00 | 60 | false | ```\nclass Solution {\n func smallestEqual(_ nums: [Int]) -> Int {\n nums.indices.first { $0 % 10 == nums[$0] } ?? -1\n }\n}\n``` | 3 | 0 | ['Swift'] | 0 |
smallest-index-with-equal-value | C++ Code | c-code-by-deepikabajaj31-w0f4 | \nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for(int index=0;index<nums.size();index++)\n {\n if(index%10= | deepikabajaj31 | NORMAL | 2021-11-14T10:17:15.015317+00:00 | 2021-11-14T10:17:15.015350+00:00 | 374 | false | ```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for(int index=0;index<nums.size();index++)\n {\n if(index%10==nums[index])\n return index;\n }\n return -1;\n }\n};\n``` | 3 | 0 | ['C', 'C++'] | 0 |
smallest-index-with-equal-value | Rust one liner solutions | rust-one-liner-solutions-by-bigmih-lfc8 | Simple solution with MOD-operation\n\nimpl Solution {\n pub fn smallest_equal(nums: Vec<i32>) -> i32 {\n nums.iter()\n .zip(0..)\n | BigMih | NORMAL | 2021-10-31T16:45:20.650714+00:00 | 2021-10-31T19:17:22.092064+00:00 | 120 | false | 1. Simple solution with MOD-operation\n```\nimpl Solution {\n pub fn smallest_equal(nums: Vec<i32>) -> i32 {\n nums.iter()\n .zip(0..)\n .position(|(x, i)| i % 10 == *x)\n .map_or(-1, |i| i as i32)\n }\n}\n```\n2. Solution with cycle index (w/o MOD)\n```\nimpl Solution {\n pub fn smallest_equal(nums: Vec<i32>) -> i32 {\n nums.iter()\n .zip((0..10).cycle())\n .position(|(x, i)| i == *x)\n .map_or(-1, |i| i as i32)\n }\n}\n``` | 3 | 0 | ['Rust'] | 1 |
smallest-index-with-equal-value | Smallest Index With Equal Value 🧑💻🧑💻 || JAVA solution code 💁💁... | smallest-index-with-equal-value-java-sol-dwea | \n\n# Code\n\nclass Solution {\n public int smallestEqual(int[] nums) {\n for(int i=0; i<nums.length; i++) {\n if(i % 10 == nums[i]) {\n | ANKITBI1713 | NORMAL | 2024-05-16T08:35:35.030877+00:00 | 2024-05-16T08:35:35.030915+00:00 | 328 | false | \n\n# Code\n```\nclass Solution {\n public int smallestEqual(int[] nums) {\n for(int i=0; i<nums.length; i++) {\n if(i % 10 == nums[i]) {\n return i;\n }\n }\n return -1;\n }\n}\n``` | 2 | 0 | ['Java'] | 1 |
smallest-index-with-equal-value | Simple Solution | simple-solution-by-adwxith-hnui | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | adwxith | NORMAL | 2023-11-20T15:06:33.460548+00:00 | 2023-11-20T15:06:33.460580+00:00 | 72 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar smallestEqual = function(nums) {\n for(let i=0;i<nums.length;i++){\n if(i%10==nums[i]) return i\n }\n return -1\n};\n``` | 2 | 0 | ['JavaScript'] | 0 |
smallest-index-with-equal-value | Easy solution -beats 100% | easy-solution-beats-100-by-shivamtiwari2-a1sa | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | ShivamTiwari214 | NORMAL | 2023-11-17T15:00:59.676285+00:00 | 2023-11-17T15:00:59.676317+00:00 | 23 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:$$O(n)$$ \n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$ \n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n \n for ( int i = 0 ; i < nums.size() ; i++ ) {\n if( i % 10 == nums[i]) return i ;\n }\n return -1;\n }\n};\n``` | 2 | 0 | ['C++'] | 0 |
smallest-index-with-equal-value | Easy JavaScript solution [Beats 98.97%] | easy-javascript-solution-beats-9897-by-r-1bu3 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | RahulBadwaya | NORMAL | 2023-07-22T14:02:22.025031+00:00 | 2023-07-22T14:02:22.025055+00:00 | 157 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar smallestEqual = function(nums) {\n for(let i=0; i<nums.length; i++) {\n if(i%10 === nums[i]) return i\n }\n return -1\n};\n``` | 2 | 0 | ['JavaScript'] | 0 |
smallest-index-with-equal-value | Java | very easy solution | Beats 100% | O(n) => (^___^) | java-very-easy-solution-beats-100-on-___-oszi | Have fun with my code (^__^)\n\nclass Solution {\n public int smallestEqual(int[] nums) {\n for (int i = 0; i < nums.length; i++)\n if (i % | ate3f | NORMAL | 2023-03-31T22:04:43.570934+00:00 | 2023-03-31T22:04:43.570980+00:00 | 716 | false | # Have fun with my code (^__^)\n```\nclass Solution {\n public int smallestEqual(int[] nums) {\n for (int i = 0; i < nums.length; i++)\n if (i % 10 == nums[i])\n return i;\n return -1;\n }\n}\n``` | 2 | 0 | ['Java'] | 1 |
smallest-index-with-equal-value | Simple solution on Swift | simple-solution-on-swift-by-blackbirdng-03dr | Code\n\nclass Solution {\n func smallestEqual(_ nums: [Int]) -> Int {\n for i in 0..<nums.count where i % 10 == nums[i] {\n return i\n | blackbirdNG | NORMAL | 2023-01-07T11:17:11.693729+00:00 | 2023-01-07T11:17:11.693771+00:00 | 212 | false | # Code\n```\nclass Solution {\n func smallestEqual(_ nums: [Int]) -> Int {\n for i in 0..<nums.count where i % 10 == nums[i] {\n return i\n }\n return -1\n }\n}\n```\n### Please upvote if you found the solution useful! | 2 | 0 | ['Swift'] | 0 |
smallest-index-with-equal-value | JAVA | Short and Simple ✅ | java-short-and-simple-by-sourin_bruh-3mkr | Please Upvote :D\n\nclass Solution {\n public int smallestEqual(int[] nums) {\n int min = 101;\n\n for (int i = 0; i < nums.length; i++) {\n | sourin_bruh | NORMAL | 2022-11-09T18:43:47.518865+00:00 | 2022-11-09T18:43:47.518909+00:00 | 363 | false | ### **Please Upvote** :D\n```\nclass Solution {\n public int smallestEqual(int[] nums) {\n int min = 101;\n\n for (int i = 0; i < nums.length; i++) {\n if (i % 10 == nums[i]) {\n min = Math.min(min, i);\n }\n }\n\n return min == 101 ? -1 : min;\n }\n}\n\n// TC: O(n), SC: O(1)\n``` | 2 | 0 | ['Java'] | 0 |
smallest-index-with-equal-value | python3 || best solution | python3-best-solution-by-omkar211-3cl5 | \nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n for i in range(len(nums)):\n if i%10==nums[i]:\n retu | omkar211 | NORMAL | 2022-09-17T22:43:48.142643+00:00 | 2022-09-17T22:43:48.142683+00:00 | 346 | false | ```\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``` | 2 | 0 | ['Python'] | 0 |
smallest-index-with-equal-value | Java Easy Solution | java-easy-solution-by-priyankan_23-a2ey | \nclass Solution {\n public int smallestEqual(int[] nums) {\n for(int i=0;i<nums.length;i++) {\n if(i%10==nums[i]) { \n return | priyankan_23 | NORMAL | 2022-09-13T18:34:17.517796+00:00 | 2022-09-13T18:34:17.517853+00:00 | 540 | false | ```\nclass Solution {\n public int smallestEqual(int[] nums) {\n for(int i=0;i<nums.length;i++) {\n if(i%10==nums[i]) { \n return i;\n \n }\n}\n return -1;\n }\n}\n``` | 2 | 0 | ['Java'] | 0 |
smallest-index-with-equal-value | EASY SOLUTION 100% JAVA or C++ 😉😉👍👍 | easy-solution-100-java-or-c-by-azamovme-9bnh | \n\n\n \n\n\n\n\n# C++ Solution\n\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n // i mod 10 == nums[i]\n for(int i=0;i | azamovme | NORMAL | 2022-08-28T14:23:24.634852+00:00 | 2022-08-28T14:24:10.818610+00:00 | 397 | false | \n\n<p align="center">\n <a href="https://github.com/professorDeveloper"><img src="https://readme-typing-svg.herokuapp.com?font=Time+New+Roman&color=%23C8BE25&size=25¢er=true&vCenter=true&width=500&height=100&lines=I+am+Hud+Azamov;I+am+Mobile+Developer;Hello+LeetCode;Mobile+Programmer;I+am+from+Uzbekistan;My+best+code+Kotlin;\uD83C\uDF31+I\u2019m+currently+learning+Flutter;\uD83D\uDC6F+I\u2019m+looking+to+collaborate+with+other+content+creators"></a>\n</p>\n\n\n\n# C++ Solution\n```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n // i mod 10 == nums[i]\n for(int i=0;i<nums.size();i++)\n if(i%10 == nums[i]) return i;\n return -1;\n }\n};\n```\n\n\n# Java Solution\n```\nclass Solution {\n public int smallestEqual(int[] nums) {\n for (int i = 0; i < nums.length; i++) {\n if (nums[i] == i % 10) {\n return i;\n }\n }\n return -1;\n }\n}\n```\n | 2 | 0 | ['Java'] | 0 |
smallest-index-with-equal-value | Easiest Javascript solution with O(n) | easiest-javascript-solution-with-on-by-b-awxm | var smallestEqual = function(nums) {\n let arr = nums.length;\n for(let i=0;i<arr;i++){\n if(i % 10== nums[i]){\n return i\n } \ | bharathcs2013 | NORMAL | 2022-08-04T07:09:59.961200+00:00 | 2022-08-04T07:10:58.353349+00:00 | 159 | false | var smallestEqual = function(nums) {\n let arr = nums.length;\n for(let i=0;i<arr;i++){\n if(i % 10== nums[i]){\n return i\n } \n }\n\n return -1\n \n}; | 2 | 0 | ['JavaScript'] | 0 |
smallest-index-with-equal-value | Easy Pizzy c++ sol | easy-pizzy-c-sol-by-richach10-03zd | \nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for(int i=0;i<nums.size();i++)\n {\n if(i%10==nums[i])\n | Richach10 | NORMAL | 2022-03-19T17:49:17.482518+00:00 | 2022-03-19T17:49:17.482562+00:00 | 123 | false | ```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for(int i=0;i<nums.size();i++)\n {\n if(i%10==nums[i])\n {\n return i;\n }\n }\n return -1;\n }\n};\n``` | 2 | 0 | ['C', 'C++'] | 0 |
smallest-index-with-equal-value | [C++} Lmao | c-lmao-by-vaibhav4859-5j3o | Just follow the description given nd it;\'s done !\n\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for(int idx = 0; idx < nums | vaibhav4859 | NORMAL | 2021-11-14T10:23:00.725769+00:00 | 2021-11-14T10:23:00.725825+00:00 | 116 | false | **Just follow the description given nd it;\'s done !**\n```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for(int idx = 0; idx < nums.size(); idx++){\n if(idx % 10 == nums[idx])\n return idx;\n }\n return -1;\n }\n};\n``` | 2 | 1 | ['C', 'C++'] | 0 |
smallest-index-with-equal-value | [Python3] easy O(N) | python3-easy-on-by-sacharya1-pdb5 | \tclass Solution:\n\t\tdef smallestEqual(self, nums: List[int]) -> int:\n\t\t\tfor idx,val in enumerate(nums):\n\t\t\t\tif idx%10==val:\n\t\t\t\t\treturn idx\n\ | sacharya1 | NORMAL | 2021-11-02T19:11:40.131299+00:00 | 2021-11-02T19:11:40.131341+00:00 | 78 | false | \tclass Solution:\n\t\tdef smallestEqual(self, nums: List[int]) -> int:\n\t\t\tfor idx,val in enumerate(nums):\n\t\t\t\tif idx%10==val:\n\t\t\t\t\treturn idx\n\t\t\treturn -1 | 2 | 1 | [] | 0 |
smallest-index-with-equal-value | Simple java solution | simple-java-solution-by-siddhant_1602-me0j | class Solution {\n\n public int smallestEqual(int[] n) {\n int k=n.length;\n for(int i=0;i<k;i++)\n {\n if(i%10==n[i])\n | Siddhant_1602 | NORMAL | 2021-11-01T14:52:42.023639+00:00 | 2022-03-08T07:06:59.245685+00:00 | 125 | false | class Solution {\n\n public int smallestEqual(int[] n) {\n int k=n.length;\n for(int i=0;i<k;i++)\n {\n if(i%10==n[i])\n return i;\n }\n return -1;\n }\n} | 2 | 0 | [] | 0 |
smallest-index-with-equal-value | C++|| EASY SOLUTION | c-easy-solution-by-prabhatpradhan097-wugf | ```\n // PLEASE UPVOTE IF YOU LIKE THE SOLUTION !!\nclass Solution {\npublic:\n int smallestEqual(vector& nums) {\n int ans =-1;\n vectork;\n | prabhatpradhan097 | NORMAL | 2021-10-31T06:21:08.909881+00:00 | 2021-10-31T06:21:08.909929+00:00 | 79 | false | ```\n // PLEASE UPVOTE IF YOU LIKE THE SOLUTION !!\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int ans =-1;\n vector<int>k;\n \n for(int i=0;i<nums.size();i++)\n {\n if(( i%10 )== nums[i])\n {\n k.push_back(i);\n ans++;\n \n }}\n if(ans!=-1)\n {\n sort(k.begin(),k.end());\n return k[0];\n }\n else\n return ans;\n \n }\n}; | 2 | 0 | ['C'] | 0 |
smallest-index-with-equal-value | Python Easy Solution | python-easy-solution-by-rnyati2000-g88k | \nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n for i in range(len(nums)):\n if i % 10 == nums[i]:\n | rnyati2000 | NORMAL | 2021-10-31T05:48:13.110474+00:00 | 2021-10-31T05:48:13.110525+00:00 | 118 | false | ```\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```\nIf u understood the code then plz UPVOTE....thnx in adv | 2 | 1 | ['Python'] | 0 |
smallest-index-with-equal-value | Simple for loop solution! | simple-for-loop-solution-by-akinmyrza-51aa | \n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar smallestEqual = function(nums) {\n let arr = [];\n \n for (let i = 0; i < nums.length; | Akinmyrza | NORMAL | 2021-10-31T04:35:29.936090+00:00 | 2021-10-31T04:36:04.358192+00:00 | 94 | false | ```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar smallestEqual = function(nums) {\n let arr = [];\n \n for (let i = 0; i < nums.length; i++){\n if(i % 10 === nums[i]){\n arr.push(i);\n } \n }\n return arr.length === 0 ? -1 : Math.min(...arr);\n};\n``` | 2 | 0 | ['JavaScript'] | 1 |
smallest-index-with-equal-value | C++ Easy understanding | 2-Approaches | Simple solution | c-easy-understanding-2-approaches-simple-3ozn | Approach-1\n\n\t\t vector<int>v;\n int ind;\n\t\t for(int i=0;i<nums.size();i++){\n\t\t\t\t if(i%10==nums[i]){\n\t\t\t\t\t v.push_back(i);\n\t\t\t | aryans_1319 | NORMAL | 2021-10-31T04:10:46.379586+00:00 | 2021-10-31T04:10:46.379628+00:00 | 70 | false | **Approach-1**\n```\n\t\t vector<int>v;\n int ind;\n\t\t for(int i=0;i<nums.size();i++){\n\t\t\t\t if(i%10==nums[i]){\n\t\t\t\t\t v.push_back(i);\n\t\t\t }\n\t\t } \n if(v.size()==0){\n\t\t\t\tind=-1;\n\t\t\t}\n else{\n ind= *min_element(v.begin(),v.end());\n }\n return ind;\n\t\t\n```\n**Approach-2**\n```\n\t\tfor(int i = 0; i < nums.size(); i++){\n\t\t\tif(nums[i] == i%10){\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn -1; | 2 | 2 | ['C'] | 0 |
smallest-index-with-equal-value | [Rust] Solution | rust-solution-by-u3ih-ua6k | ```\nimpl Solution {\n pub fn smallest_equal(nums: Vec) -> i32 {\n for (i, v) in nums.iter().enumerate() {\n if i%10 == *v as usize {\n | u3ih | NORMAL | 2021-10-31T04:06:51.035671+00:00 | 2021-11-06T03:40:03.921488+00:00 | 70 | false | ```\nimpl Solution {\n pub fn smallest_equal(nums: Vec<i32>) -> i32 {\n for (i, v) in nums.iter().enumerate() {\n if i%10 == *v as usize {\n return i as i32;\n }\n }\n return -1;\n }\n} | 2 | 0 | ['Rust'] | 0 |
smallest-index-with-equal-value | <<BEAT 100% SOLUTIONS>> | beat-100-solutions-by-dakshesh_vyas123-aqip | PLEASE UPVOTE MECode | Dakshesh_vyas123 | NORMAL | 2025-03-22T09:38:49.558350+00:00 | 2025-03-22T09:38:49.558350+00:00 | 25 | false | # PLEASE UPVOTE ME
# Code
```cpp []
class Solution {
public:
int smallestEqual(vector<int>& nums) {
int a=-1;
for(int i=0;i<nums.size();i++){
if(i%10==nums[i]){
a=i;
break;
}
}
return a;
}
};
``` | 1 | 0 | ['C++'] | 0 |
smallest-index-with-equal-value | 100% Beats, Easy and Optimal Approach For Beginners. | 100-beats-easy-and-optimal-approach-for-kvzx0 | IntuitionApproachBruteForce ApproachComplexity
Time complexity:
Space complexity:
Code | sainathv | NORMAL | 2025-02-27T03:17:48.130236+00:00 | 2025-02-27T03:17:48.130236+00:00 | 45 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
BruteForce Approach
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(N)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(1)
# Code
```java []
class Solution {
public int smallestEqual(int[] nums) {
int index = -1;
for(int i=0; i<nums.length; i++){
if( i % 10 == nums[i]){
index = i;
break;
}
}
return index;
}
}
``` | 1 | 0 | ['Array', 'Java'] | 0 |
smallest-index-with-equal-value | 0MS 🏆 || 5 LINE 🌟 || JAVA ☕ | 0ms-5-line-java-by-galani_jenis-nvj9 | Code | Galani_jenis | NORMAL | 2025-01-23T04:24:42.774650+00:00 | 2025-01-23T04:24:42.774650+00:00 | 65 | false | 
# Code
```java []
class Solution {
public int smallestEqual(int[] nums) {
for (int i = 0; i < nums.length; i++) {
if (i % 10 == nums[i]) {
return i;
}
}
return -1;
}
}
```

| 1 | 0 | ['Java'] | 0 |
smallest-index-with-equal-value | python3 beats 100% | python3-beats-100-by-pranaviguddanti-o57z | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | PranaviGuddanti | NORMAL | 2025-01-06T16:32:41.507275+00:00 | 2025-01-06T16:32:41.507275+00:00 | 89 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```python3 []
class Solution:
def smallestEqual(self, nums: List[int]) -> int:
l=[]
for i in range(0,len(nums)):
if i%10==nums[i]:
l.append(i)
break
if l==[]:
return -1
else:
return i
``` | 1 | 0 | ['Python3'] | 0 |
smallest-index-with-equal-value | Leetcodedaybyday - https://www.threads.net/@leetcodedaybyday | leetcodedaybyday-httpswwwthreadsnetleetc-ujwp | 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 | tuanlong1106 | NORMAL | 2024-12-13T05:35:19.514148+00:00 | 2024-12-13T05:35:19.514148+00:00 | 56 | false | # 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``` | 1 | 0 | ['C++', 'Python3'] | 0 |
smallest-index-with-equal-value | Smallest Index With Equal Value | smallest-index-with-equal-value-by-tejde-zrcu | Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem is about finding the smallest index i in an array nums where the value at t | tejdekiwadiya | NORMAL | 2024-06-04T11:49:53.791533+00:00 | 2024-06-04T11:49:53.791560+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem is about finding the smallest index `i` in an array `nums` where the value at that index is equal to `i % 10`. This involves checking each element of the array to see if it meets the condition.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. **Initialization**: Start with the index `i` initialized to 0.\n2. **Iteration**: Use a `while` loop to iterate through the array from the beginning to the end.\n - For each index `i`, check if the value at `nums[i]` is equal to `i % 10`.\n - If the condition is met, return the index `i`.\n - Otherwise, increment `i` and continue the loop.\n3. **Return**: If the loop completes without finding any such index, return `-1`.\n\n# Complexity\n- **Time complexity**: \n - The time complexity is \\(O(n)\\), where \\(n\\) is the length of the array `nums`. This is because, in the worst case, we may need to check each element of the array once.\n \n- **Space complexity**: \n - The space complexity is \\(O(1)\\) because the algorithm uses a constant amount of extra space regardless of the input size.\n\n# Code\n\n```java\nclass Solution {\n public int smallestEqual(int[] nums) {\n int i = 0; // Initialize the index i to 0\n while (i < nums.length) { // Loop through the array\n if (nums[i] == i % 10) { // Check if the value at nums[i] equals i % 10\n return i; // If condition is met, return the current index i\n }\n i++; // Increment the index\n }\n return -1; // If no such index is found, return -1\n }\n}\n```\n\n# Example Walkthrough\n\nLet\'s go through an example to understand how this code works:\n\n**Example 1**:\n- Input: `nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]`\n- The loop checks each element:\n - `nums[0] == 0 % 10` (true), so the function returns `0`.\n\n**Example 2**:\n- Input: `nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]`\n- The loop checks each element:\n - `nums[0] == 0 % 10` (false)\n - `nums[1] == 1 % 10` (true), so the function returns `1`.\n\nIn both examples, the function finds the smallest index that meets the condition or returns `-1` if no such index exists. | 1 | 0 | ['Array', 'Java'] | 0 |
smallest-index-with-equal-value | Easy solution C++ | easy-solution-c-by-yogiraj_chaukhande-5phw | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nFirst analyze the problem then in one for loop return i smallest index .\ | YPC_151 | NORMAL | 2024-05-08T06:36:43.164230+00:00 | 2024-05-08T06:36:43.164262+00:00 | 15 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nFirst analyze the problem then in one for loop return i smallest index .\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int r=-1;\n for(int i=0;i<nums.size();i++){\n r= i % 10;\n if(r == nums[i]){\n return i;\n }\n }\n return -1;\n \n }\n};\n``` | 1 | 0 | ['C++'] | 1 |
smallest-index-with-equal-value | Easy Solution with time complexity of 0ms 🔥🔥🔥 | easy-solution-with-time-complexity-of-0m-qg7w | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | 717821f253 | NORMAL | 2024-01-19T09:22:42.591338+00:00 | 2024-01-19T09:22:42.591356+00:00 | 78 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int smallestEqual(int[] nums) {\n int ans=-1,a=0;\n for(int i=0;i<nums.length;i++)\n {\n a=i%10;\n if(a==nums[i])\n {\n ans=i;\n break;\n }\n }\n return ans;\n }\n}\n``` | 1 | 0 | ['Java'] | 1 |
smallest-index-with-equal-value | python easy solution! | python-easy-solution-by-ajaydev1-lhru | Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition for this problem is to iterate through the indices and values of the give | Ajaydev1 | NORMAL | 2023-11-20T06:33:03.382840+00:00 | 2023-11-20T06:33:03.382859+00:00 | 8 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition for this problem is to iterate through the indices and values of the given list nums and check for the condition where the index modulo 10 is equal to the value at that index.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe approach is straightforward. We use a loop to iterate through each index and value in the nums list. For each iteration, we check if the index modulo 10 is equal to the value at that index (i % 10 == nums[i]). If this condition is true, we return the current index. If no such index is found, we return -1\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nTime complexity: O(n), where n is the length of the input list nums. The loop iterates through each element once\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nSpace complexity: O(1), as we are using a constant amount of space, and the space doesn\'t depend on the input size.\n# Code\n```\nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n for i , num in enumerate(nums):\n if i % 10 == num:\n return i\n return -1\n \n\n``` | 1 | 0 | ['Python3'] | 0 |
smallest-index-with-equal-value | Py solution simple | py-solution-simple-by-gnairju-lh5a | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | gnairju | NORMAL | 2023-11-20T04:29:02.892178+00:00 | 2023-11-20T04:29:02.892203+00:00 | 262 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n lst=[]\n for i in range(len(nums)):\n if i%10==nums[i]:\n lst.append(i)\n if len(lst)>=1:\n return min(lst)\n else:\n return -1\n``` | 1 | 0 | ['Python3'] | 1 |
smallest-index-with-equal-value | easy solution | beats 100% | easy-solution-beats-100-by-leet1101-apt0 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | leet1101 | NORMAL | 2023-11-17T15:24:28.806899+00:00 | 2023-11-17T15:24:28.806921+00:00 | 412 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\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``` | 1 | 0 | ['Array', 'C++'] | 0 |
smallest-index-with-equal-value | BEGGINER FRIENDLY APPROACH || BEATS 90.39% || 2 LINE CODE || 🔥🔥🔥✅✅✅ | begginer-friendly-approach-beats-9039-2-rhv1j | Approach\n Describe your approach to solving the problem. \nUsing list comprehension we can store all the possible results in a list and then return the minimum | chorko_c | NORMAL | 2023-11-02T02:56:21.304386+00:00 | 2023-11-02T02:56:21.304421+00:00 | 4 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\nUsing list comprehension we can store all the possible results in a list and then return the minimum value from that list.\n\n# Code\n```\nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n l=[i for i in range(len(nums)) if i%10==nums[i]]\n\n return min(l) if len(l)>0 else -1\n```\n# Proof\n\n\n | 1 | 0 | ['Python3'] | 0 |
smallest-index-with-equal-value | Best easy solution in c++ | best-easy-solution-in-c-by-rajp969375994-qent | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | rajp9693759948 | NORMAL | 2023-07-27T20:19:53.939738+00:00 | 2023-07-27T20:19:53.939756+00:00 | 51 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int n=nums.size();\n\n for(int i=0;i<n;i++){\n if(i % 10 == nums[i]){\n return i;\n }\n\n }\n return -1;\n }\n};\n``` | 1 | 0 | ['C++'] | 0 |
smallest-index-with-equal-value | Smallest Index With Equal Value 🧑💻🧑💻 || JAVA solution code 💁💁... | smallest-index-with-equal-value-java-sol-o314 | Code\n\nclass Solution {\n public int smallestEqual(int[] nums) {\n int ans = 0;\n int temp = 0;\n int n = 0;\n for(int i=0; i<nu | Jayakumar__S | NORMAL | 2023-07-02T16:28:04.340048+00:00 | 2023-07-02T16:28:04.340069+00:00 | 200 | false | # Code\n```\nclass Solution {\n public int smallestEqual(int[] nums) {\n int ans = 0;\n int temp = 0;\n int n = 0;\n for(int i=0; i<nums.length; i++){\n if(i%10 == nums[i]){\n temp = i;\n\n if(n == 0){\n ans = i;\n n++;\n }\n \n if(ans > temp){\n ans = temp;\n }\n\n }\n }\n if(n != 0){\n return ans;\n }\n return -1;\n }\n}\n``` | 1 | 0 | ['Java'] | 0 |
smallest-index-with-equal-value | Simple JAVA Solution. | simple-java-solution-by-sohaebahmed-zmgp | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | sohaebAhmed | NORMAL | 2023-06-27T17:26:38.891153+00:00 | 2023-06-27T17:26:38.891192+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int smallestEqual(int[] nums) {\n int smallestIndex = Integer.MAX_VALUE;\n for(int i = 0; i < nums.length; i++) {\n if(i % 10 == nums[i]) {\n smallestIndex = Integer.min(smallestIndex, i);\n }\n if(i == nums.length - 1 && smallestIndex == Integer.MAX_VALUE) {\n return -1;\n }\n }\n return smallestIndex;\n }\n}\n``` | 1 | 0 | ['Array', 'Java'] | 0 |
smallest-index-with-equal-value | c++ solution --> very simple-->O(n) | c-solution-very-simple-on-by-aniket2241-esgj | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nNo need to traverse all array when found one value simply break, as only | aniket2241 | NORMAL | 2023-05-20T19:38:21.935733+00:00 | 2023-05-20T19:38:21.935759+00:00 | 607 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nNo need to traverse all array when found one value simply break, as only minimum value is required.If value is not find ans intialized with -1 will be returned.\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int ans=-1;\n for(int i=0;i<nums.size();i++){\n \n if(i%10==nums[i]){\n ans=i;\n break;\n }\n }\n return ans; }\n};\n``` | 1 | 0 | ['C++'] | 0 |
smallest-index-with-equal-value | Super Logic Using Python3 | super-logic-using-python3-by-gpraveen-pnwg | \n\n# Simple explained Solution In Python3\n\nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n list1=[]\n for i in range(le | GPraveen | NORMAL | 2023-05-11T16:55:57.263993+00:00 | 2023-05-11T16:55:57.264042+00:00 | 525 | false | \n\n# Simple explained Solution In Python3\n```\nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n list1=[]\n for i in range(len(nums)):\n if((i%10) == nums[i]):\n list1.append(i)\n if len(nums)==len(list1):\n return 0\n if list1:\n return list1[0]\n return -1\n``` | 1 | 0 | ['Python3'] | 0 |
smallest-index-with-equal-value | Smallest Index With Equal Value Solution in C++ | smallest-index-with-equal-value-solution-3d8x | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | The_Kunal_Singh | NORMAL | 2023-03-19T15:47:59.666068+00:00 | 2023-03-19T15:47:59.666114+00:00 | 28 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n# Code\n```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int i;\n for(i=0 ; i<nums.size() ; i++)\n {\n if(i%10==nums[i])\n {\n return i;\n }\n }\n return -1;\n }\n};\n``` | 1 | 0 | ['C++'] | 0 |
smallest-index-with-equal-value | Easy Solution | Java | Python | easy-solution-java-python-by-atharva77-z6or | Java\n\nclass Solution {\n public int smallestEqual(int[] nums) {\n for(int i=0; i<nums.length; i++) {\n if(i % 10 == nums[i]) {\n | atharva77 | NORMAL | 2023-03-19T06:05:39.532845+00:00 | 2023-03-19T06:05:39.532883+00:00 | 258 | false | # Java\n```\nclass Solution {\n public int smallestEqual(int[] nums) {\n for(int i=0; i<nums.length; i++) {\n if(i % 10 == nums[i]) {\n return i;\n }\n }\n return -1;\n }\n}\n```\n# Python\n```\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```\nDo upvote if you like the Solution :) | 1 | 0 | ['Java', 'Python3'] | 0 |
smallest-index-with-equal-value | ✅ [C++] EASY and Shorter Solution || Intuitive Approach | c-easy-and-shorter-solution-intuitive-ap-vgqb | \n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n\n | akh1465 | NORMAL | 2023-03-18T04:55:33.888264+00:00 | 2023-03-18T04:55:33.888308+00:00 | 114 | false | \n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n\n int i,n = nums.size();\n int value=0;\n int f=0;\n\n for(i=0;i<n;i++)\n {\n value = i%10;\n if(value==nums[i])\n {\n f=1;\n break;\n }\n }\n if(f==1)\n return i;\n else\n return -1;\n \n }\n};\n``` | 1 | 0 | ['C++'] | 0 |
smallest-index-with-equal-value | C++ - Solution - Self Explanatory | c-solution-self-explanatory-by-nipunrath-b0fx | # Intuition \n\n\n\n\n\n# Complexity\n- Time complexity:O(n)\n\n\n- Space complexity:O(1)\n\n\n# Code\n\nclass Solution {\npublic:\n int smallestEqual(vect | nipunrathore | NORMAL | 2023-02-06T16:15:10.637080+00:00 | 2023-02-06T16:15:10.637129+00:00 | 232 | false | <!-- # Intuition -->\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n<!-- # Approach -->\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:$$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n for (int i = 0 ; i < nums.size() ; i ++)\n {\n if ( (i % 10) == nums[i] )\n {\n return i ;\n }\n }\n return -1; \n }\n};\n```\n\n | 1 | 0 | ['Array', 'C++'] | 0 |
smallest-index-with-equal-value | Linear Search || O(N) time || O(1) space | linear-search-on-time-o1-space-by-shrist-0n2s | \n\n# Code\n\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int val=-1;\n for(int i=0;i<nums.size();i++){\n i | Shristha | NORMAL | 2023-02-02T03:35:14.668406+00:00 | 2023-02-02T03:35:14.668438+00:00 | 528 | false | \n\n# Code\n```\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int val=-1;\n for(int i=0;i<nums.size();i++){\n if(i%10==nums[i])return i;\n }\n return val;\n \n }\n};\n``` | 1 | 0 | ['C++'] | 0 |
smallest-index-with-equal-value | c++||easy | ceasy-by-suryakant17-rd2f | class Solution {\npublic:\n int smallestEqual(vector& nums) {\n int n=nums.size();\n int count=0;\n int mn=INT_MAX;\n for(int i=0 | suryakant17 | NORMAL | 2022-12-04T08:21:45.796718+00:00 | 2022-12-04T08:21:45.796750+00:00 | 498 | false | class Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int n=nums.size();\n int count=0;\n int mn=INT_MAX;\n for(int i=0;i<n;i++){\n if(i%10==nums[i]){\n count=1;\n mn=min(mn,i);\n }\n }\n if(count==1)\n return mn;\n else\n return -1;\n \n }\n}; | 1 | 0 | [] | 0 |
smallest-index-with-equal-value | ✔✔JAVA || Simple Logic || Linear solution || 2ms | java-simple-logic-linear-solution-2ms-by-bkom | \nclass Solution {\n public int smallestEqual(int[] nums) {\n \n for(int i=0;i<nums.length;i++){\n if(i%10==nums[i]) return i; \n | gauravpatyal2702 | NORMAL | 2022-11-10T04:33:38.888587+00:00 | 2022-11-10T04:33:54.781268+00:00 | 25 | false | ```\nclass Solution {\n public int smallestEqual(int[] nums) {\n \n for(int i=0;i<nums.length;i++){\n if(i%10==nums[i]) return i; \n }\n return -1;\n }\n}\n```\n\n\n**Any Doubt ask down below :-D** | 1 | 0 | ['Java'] | 0 |
smallest-index-with-equal-value | Python Sol^n | python-soln-by-aditya-1967-im0y | \nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n ans = []\n for i in range(len(nums)):\n if i % 10 == nums[i]: | aditya-1967 | NORMAL | 2022-11-07T07:42:22.969119+00:00 | 2022-11-07T07:42:22.969155+00:00 | 258 | false | ```\nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n ans = []\n for i in range(len(nums)):\n if i % 10 == nums[i]:\n ans.append(i)\n \n return min(ans) if len(ans) > 0 else -1\n``` | 1 | 0 | [] | 0 |
smallest-index-with-equal-value | Python O(N) | python-on-by-sneh713-ouas | Intuition JUET\n Describe your first thoughts on how to solve this problem. \n\n# Approach easy understanding \n Describe your approach to solving the problem. | Sneh713 | NORMAL | 2022-09-30T04:42:57.533459+00:00 | 2022-09-30T04:42:57.533503+00:00 | 370 | false | # Intuition JUET\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach easy understanding \n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: best: O(1)\n- wrost :O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n def smallestEqual(self, nums: List[int]) -> int:\n n=len(nums)\n for i in range(n):\n if i%10==nums[i]:\n return i\n return -1\n``` | 1 | 0 | ['Array', 'Python3'] | 0 |
smallest-index-with-equal-value | Java Solution | java-solution-by-pawan300-wtdh | ```\n public int smallestEqual(int[] nums) {\n int res =-1;\n for(int i=0;i<nums.length;i++){\n if(i%10==nums[i]){\n ret | pawan300 | NORMAL | 2022-09-23T19:03:27.982221+00:00 | 2022-09-23T19:03:27.982271+00:00 | 169 | false | ```\n public int smallestEqual(int[] nums) {\n int res =-1;\n for(int i=0;i<nums.length;i++){\n if(i%10==nums[i]){\n return i;\n }\n }\n return res;\n \n } | 1 | 0 | ['Array'] | 0 |
smallest-index-with-equal-value | Java 100% || Clear Solution|| No comment | java-100-clear-solution-no-comment-by-ja-73n0 | class Solution {\n public int smallestEqual(int[] nums) {\n for(int i = 0; i < nums.length; i++){\n if(i%10==nums[i]){\n ret | Jaloliddin_1109 | NORMAL | 2022-09-18T03:47:13.688591+00:00 | 2022-09-18T03:47:13.688620+00:00 | 263 | false | class Solution {\n public int smallestEqual(int[] nums) {\n for(int i = 0; i < nums.length; i++){\n if(i%10==nums[i]){\n return i;\n }\n }\n return -1;\n }\n} | 1 | 0 | ['Java'] | 0 |
smallest-index-with-equal-value | With Explanation Comments: Time: 24 ms (30.31%), Space: 22 MB (78.76%) | with-explanation-comments-time-24-ms-303-mszp | Like it? ->Upvote please! \u30C4\n\n\'\'\'\nclass Solution {\npublic:\n int smallestEqual(vector& nums) {\n \n //loop over the whole array elem | deleted_user | NORMAL | 2022-09-17T18:59:41.447943+00:00 | 2022-09-17T18:59:41.447985+00:00 | 216 | false | **Like it? ->Upvote please!** \u30C4\n\n\'\'\'\nclass Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n \n //loop over the whole array elements\n for(int i=0;i<nums.size();i++)\n //check if the current index is divisible by the current value\n if(i%10==nums[i])\n //if yes-> return the valid index\n return i;\n \n //if no-> return -1\n return -1;\n }\n};\n\'\'\'\n\n**Like it? ->Upvote please!** \u30C4\n**If still not understood, feel free to comment. I will help you out**\n**Happy Coding :)** | 1 | 0 | ['Array', 'C', 'C++'] | 0 |
smallest-index-with-equal-value | java || 1ms || 100% faster || 3 line solution | java-1ms-100-faster-3-line-solution-by-_-9sii | class Solution {\n public int smallestEqual(int[] nums) {\n\n for(int i=0;i<nums.length;i++){\n if(nums[i]%10==i%10){\n retu | __nf3 | NORMAL | 2022-09-08T11:49:16.805935+00:00 | 2022-09-08T11:49:39.587377+00:00 | 164 | false | class Solution {\n public int smallestEqual(int[] nums) {\n\n for(int i=0;i<nums.length;i++){\n if(nums[i]%10==i%10){\n return i;\n }\n }\n return -1;\n }\n} | 1 | 0 | ['Java'] | 0 |
smallest-index-with-equal-value | 100% T.C. easy short solution | 100-tc-easy-short-solution-by-hurshidbek-x8t8 | \nPLEASE UPVOTE IF YOU LIKE\n\n```\n for (int i = 0; i < nums.length; i++) {\n if (i % 10 == nums[i]){\n return i;\n | Hurshidbek | NORMAL | 2022-08-29T20:01:45.168866+00:00 | 2022-08-29T20:01:45.168909+00:00 | 58 | false | ```\nPLEASE UPVOTE IF YOU LIKE\n```\n```\n for (int i = 0; i < nums.length; i++) {\n if (i % 10 == nums[i]){\n return i;\n }\n }\n return -1; | 1 | 0 | ['Java'] | 0 |
smallest-index-with-equal-value | C++ Easy Solution || 100% Easy Solution || Only Using Simple Loop | c-easy-solution-100-easy-solution-only-u-yt6b | Easiest C++ Solution\n\nclass Solution {\npublic:\n int smallestEqual(vector& nums) {\n int n = nums.size();\n int finalans = -1;\n for( | amit24x | NORMAL | 2022-08-17T10:56:49.201123+00:00 | 2022-08-17T10:57:13.601237+00:00 | 217 | false | # Easiest C++ Solution\n\n**class Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n int n = nums.size();\n int finalans = -1;\n for(int i=0;i<n;i++)\n {\n if(i%10==nums[i])\n {\n finalans = i;\n break;\n }\n }\n return finalans;\n }\n};** | 1 | 0 | ['C', 'C++'] | 1 |
smallest-index-with-equal-value | 100.00% FASTER JAVA SOLUTION | 10000-faster-java-solution-by-alperkaya0-nh5r | This question is a waste of time if you are not a beginner.\n\nclass Solution {\n public int smallestEqual(int[] nums) {\n int res = -1;\n for | alperkaya0 | NORMAL | 2022-08-09T00:37:53.706323+00:00 | 2022-08-09T00:38:42.334265+00:00 | 47 | false | This question is a waste of time if you are not a beginner.\n```\nclass Solution {\n public int smallestEqual(int[] nums) {\n int res = -1;\n for (int i = 0; i< nums.length; ++i) {\n if (i%10==nums[i]) {\n res = i;\n break;\n }\n }\n return res;\n }\n}\n``` | 1 | 0 | ['Java'] | 0 |
smallest-index-with-equal-value | C++ || 3 lines code || Easiest ig | c-3-lines-code-easiest-ig-by-girdharnish-csr9 | class Solution {\npublic:\n int smallestEqual(vector& nums) {\n \n for(int i = 0; i < nums.size(); i++){\n if(i % 10 == nums[i]) ret | girdharnishant | NORMAL | 2022-08-02T11:31:14.281784+00:00 | 2022-08-02T11:31:14.281824+00:00 | 229 | false | class Solution {\npublic:\n int smallestEqual(vector<int>& nums) {\n \n for(int i = 0; i < nums.size(); i++){\n if(i % 10 == nums[i]) return i;\n }\n return -1;\n }\n}; | 1 | 0 | ['C', 'C++'] | 2 |
smallest-index-with-equal-value | c++ Easiest Approach | c-easiest-approach-by-sagarkesharwnnni-a9a8 | \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 | sagarkesharwnnni | NORMAL | 2022-07-28T21:30:26.670966+00:00 | 2022-07-28T21:30:26.670996+00:00 | 38 | false | ```\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 | 1 | 0 | ['C'] | 0 |
smallest-index-with-equal-value | Smallest Index With Equal Value || C++ || CPP | smallest-index-with-equal-value-c-cpp-by-5eyu | 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 | ASA_HELPER | NORMAL | 2022-07-20T05:49:05.130171+00:00 | 2022-07-20T05:49:05.130217+00:00 | 87 | false | 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!!!** | 1 | 0 | ['C', 'C++'] | 0 |
smallest-index-with-equal-value | 100 % faster | 100-faster-by-sdas1234-iiis | \nclass Solution {\n public int smallestEqual(int[] nums) {\n \n for(int i=0; i<nums.length; i++)\n {\n if(i%10==nums[i])\n | SDAS1234 | NORMAL | 2022-06-09T00:49:53.225644+00:00 | 2022-06-09T00:49:53.225676+00:00 | 73 | false | ```\nclass Solution {\n public int smallestEqual(int[] nums) {\n \n for(int i=0; i<nums.length; i++)\n {\n if(i%10==nums[i])\n {\n return i;\n }\n }\n return -1;\n }\n}\n``` | 1 | 0 | [] | 0 |
smallest-index-with-equal-value | simple smooth || c++ solution || cpp || easy understand | simple-smooth-c-solution-cpp-easy-unders-11cj | \t// simple smooth\n\t\n\tclass Solution {\n\tpublic:\n\t\tint smallestEqual(vector& nums) {\n\t\t\tint i = 0;\n\t\t\twhile( i < nums.size() && i % 10 != nums[ | Arvind-NITW | NORMAL | 2022-06-05T10:38:48.732804+00:00 | 2022-06-05T10:38:48.732835+00:00 | 61 | false | \t// simple smooth\n\t\n\tclass Solution {\n\tpublic:\n\t\tint smallestEqual(vector<int>& nums) {\n\t\t\tint i = 0;\n\t\t\twhile( i < nums.size() && i % 10 != nums[i]) i++; \n\t\t\treturn i >= nums.size() ? -1 : i;\n\t\t}\n\t}; | 1 | 0 | ['C', 'C++'] | 0 |
smallest-index-with-equal-value | simple.. | simple-by-vinita645-hb1y | \tclass Solution {\n\t\tpublic int smallestEqual(int[] nums) {\n\t\t\tfor(int i=0;i<nums.length;i++){\n\t\t\t\tif(i%10==nums[i]){\n\t\t\t\t\treturn i;\n\t\t\t\t | vinita645 | NORMAL | 2022-06-05T10:35:52.972930+00:00 | 2022-06-05T10:35:52.972958+00:00 | 42 | false | \tclass Solution {\n\t\tpublic int smallestEqual(int[] nums) {\n\t\t\tfor(int i=0;i<nums.length;i++){\n\t\t\t\tif(i%10==nums[i]){\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn -1;\n\t\t}\n\t} | 1 | 0 | [] | 0 |
Subsets and Splits