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
patching-array
Easy Python solution defeat 100%
easy-python-solution-defeat-100-by-heii0-bv38
Let\'s see a situation, for example the n is 10 and nums is empty, the optimal solution to "reach" 10 is 0 1 2 4 7 15, we can find the pattern that we start fro
heii0w0rid
NORMAL
2020-12-29T13:42:34.924491+00:00
2020-12-29T13:51:38.492051+00:00
340
false
Let\'s see a situation, for example the n is 10 and `nums` is empty, the optimal solution to "reach" 10 is `0 1 2 4 7 15`, we can find the pattern that we start from `stack = [0]`, the next number should be sum of stack plus 1 equal to 1, and put 1 into stack, it become [0, 1], then the next number should be 2, the sta...
3
0
['Python']
0
patching-array
Clean and simple solution [ Java ]
clean-and-simple-solution-java-by-aakash-rgez
Code\n\nclass Solution {\n public int minPatches(int[] nums, int n) {\n int minPatch = 0, i = 0, len = nums.length;\n long currentMaxValue = 0;
aakashmv23
NORMAL
2024-06-19T08:34:09.803382+00:00
2024-06-19T08:34:09.803408+00:00
12
false
# Code\n```\nclass Solution {\n public int minPatches(int[] nums, int n) {\n int minPatch = 0, i = 0, len = nums.length;\n long currentMaxValue = 0;\n\n while(currentMaxValue < n)\n {\n if(i < len && currentMaxValue+1 >= nums[i])\n {\n currentMaxValue ...
2
0
['Java']
0
patching-array
Beats 100% in java hindi me asaan approach
beats-100-in-java-hindi-me-asaan-approac-z2ue
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
bakree
NORMAL
2024-06-16T13:23:15.487466+00:00
2024-06-16T13:23:15.487494+00:00
15
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\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n...
2
0
['Array', 'Java']
0
patching-array
Most optimal solution in java
most-optimal-solution-in-java-by-yash_ja-i34b
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
yash_jadaun
NORMAL
2024-06-16T07:14:49.025604+00:00
2024-06-16T07:14:49.025632+00:00
53
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)$$ --...
2
0
['Greedy', 'Java']
1
patching-array
C++ | 100% | Time complexity O(N) | Easy | Math | Simple
c-100-time-complexity-on-easy-math-simpl-l9ii
Intuition\n Describe your first thoughts on how to solve this problem. \n\n\nThe goal is to ensure that we can form any number in the range [1, n] using the ele
gavnish_kumar
NORMAL
2024-06-16T07:07:01.127756+00:00
2024-06-16T07:07:01.127791+00:00
78
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n![image.png](https://assets.leetcode.com/users/images/8fce702e-5d70-492f-a232-3a9b992deb31_1718520450.7429855.png)\n\nThe goal is to ensure that we can form any number in the range [1, n] using the elements in the given sorted array nums ...
2
0
['C++']
0
patching-array
Easy to understand solution | 100% Beast | Greedy Approach | c++ | python | java
easy-to-understand-solution-100-beast-gr-gxwm
Intuition\nThe problem requires ensuring that every integer in the range [1, n] can be formed by the sum of some subset of elements from the given sorted array
umeshbhatiya143
NORMAL
2024-06-16T06:32:57.258607+00:00
2024-06-16T06:32:57.258636+00:00
75
false
# Intuition\nThe problem requires ensuring that every integer in the range [1, n] can be formed by the sum of some subset of elements from the given sorted array nums. If this is not possible, we need to determine the minimum number of additional numbers (patches) needed to achieve this.\n\nThe key intuition here is to...
2
0
['Array', 'Greedy', 'Python', 'C++', 'Java', 'Python3']
1
patching-array
✏️ 100%Beats 💯 || 5 Language 🚀|| 🪩🫧Best visualization🎯|| Best formatted🍸🥂🫧✧˖°|
100beats-5-language-best-visualization-b-s0mh
\uD83C\uDF89 Screenshot \uD83D\uDCF8\n\n\n\n\n## Input \uD83D\uDCE5 \n\n One Sorted* Number Array (nums) & (N) \n\n 1 <= nums[i] <= 10^4\n\n 1 <= N <=
Prakhar-002
NORMAL
2024-06-16T05:25:45.499831+00:00
2024-06-16T05:25:45.499882+00:00
195
false
# \uD83C\uDF89 Screenshot \uD83D\uDCF8\n\n![330.png](https://assets.leetcode.com/users/images/4da4528d-c664-414e-9728-55d2b25afc20_1718510944.069194.png)\n\n\n## Input \uD83D\uDCE5 \n\n One Sorted* Number Array (nums) & (N) \n\n 1 <= nums[i] <= 10^4\n\n 1 <= N <= 2^31 - 1\n\n\n## Output \uD83D\uDCE4\n\n We...
2
0
['Array', 'Greedy', 'C', 'C++', 'Java', 'Python3', 'JavaScript']
1
patching-array
0ms
0ms-by-anil-budamakuntla-d8r4
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
ANIL-BUDAMAKUNTLA
NORMAL
2024-06-16T05:14:51.565427+00:00
2024-06-16T05:19:36.353855+00:00
12
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...
2
0
['C++']
1
patching-array
beats 100% in time,96% in space. | | easy to understand| |
beats-100-in-time96-in-space-easy-to-und-8yyg
Intuition\n Describe your first thoughts on how to solve this problem. \nthere is no intution i just wrote in page and got a pattern.\n# Approach\n Describe you
vedant_verma786
NORMAL
2024-06-16T04:56:11.175844+00:00
2024-06-16T04:56:11.175868+00:00
306
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n**there is no intution i just wrote in page and got a pattern.**\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- we took `howmanypatch=0` to store number of elements to patch,`elementToSearch=1` we will search for ...
2
0
['Array', 'Dynamic Programming', 'Java']
3
patching-array
[Kotlin]O[n] This is not hard problem, just some calculation
kotlinon-this-is-not-hard-problem-just-s-5u68
Intuition\nNaive thought\n[1] covers range 1-> 1\n[1, 2] covers range 1-> 3\n[1, 2, 4] covers range 1-> 7\n[1, 2, 4, 8] covers range 1-> 15\n\n\nNaive thought\n
anhtrungcuccua1
NORMAL
2024-06-16T04:51:50.004515+00:00
2024-06-16T04:51:50.004541+00:00
63
false
# Intuition\nNaive thought\n[1] covers range 1-> 1\n[1, 2] covers range 1-> 3\n[1, 2, 4] covers range 1-> 7\n[1, 2, 4, 8] covers range 1-> 15\n\n\nNaive thought\n[1] covers range 1-> 1\n[1, 2] covers range 1-> 3\n**[1, 2, 2]** covers range 1-> 5\n[1, 2, 2, 3] covers range 1-> 8\n\n# Code\n```\nclass Solution {\n fun...
2
0
['Kotlin']
1
patching-array
A robust solution in python#
a-robust-solution-in-python-by-anand_shu-4sfa
Intuition\nTo solve the problem of determining the minimum number of patches required to ensure that every number in the range \n[1,n] can be formed by the sum
anand_shukla1312
NORMAL
2024-06-16T03:08:50.730344+00:00
2024-06-16T03:08:50.730378+00:00
19
false
# Intuition\nTo solve the problem of determining the minimum number of patches required to ensure that every number in the range \n[1,n] can be formed by the sum of some elements in the sorted array nums, we can use a greedy algorithm.\n# Approach\n**Key Idea:**\nWe maintain a variable *miss* which represents the small...
2
0
['Iterator', 'Python3']
0
patching-array
100% BEATS|| EASY MATHS SOLUTION
100-beats-easy-maths-solution-by-anubhav-mzgk
Intuition\nIt\'s totally a mathematics problem.In maths if you can achieve any combination certain sum,and get a number sum+1,then you can make any sum combinat
anubhavkrishna
NORMAL
2024-06-16T02:27:27.504850+00:00
2024-06-16T02:27:27.504873+00:00
31
false
# Intuition\nIt\'s totally a mathematics problem.In maths if you can achieve any combination certain sum,and get a number sum+1,then you can make any sum combinations from 1 to sum*2+1\n\n# Approach\nIf the next element is not sum+1,then add sum+1 and your range becomes sum*2+1 else you can add smaller number to increa...
2
0
['C++']
0
patching-array
C++ | | Easy Solution
c-easy-solution-by-donut_7-hbbq
Intuition\n###### Given a sorted array nums and an integer n, determine the minimum number of additional elements needed so that any number from 1 to n can be f
Donut_7
NORMAL
2024-06-16T01:57:16.510615+00:00
2024-06-16T01:57:16.510633+00:00
9
false
# Intuition\n###### Given a sorted array `nums` and an integer `n`, determine the minimum number of additional elements needed so that any number from 1 to `n` can be formed as the sum of some elements in the array.\n\n---\n\n\n# Approach\n\n### Approach\n1. **Initialization**: \n - Set `sum = 0` to track the maximum...
2
0
['C++']
0
patching-array
Easy Peasy 🔥|0 ms | Java || C||| Python
easy-peasy-0-ms-java-c-python-by-ravipar-m6gs
\npublic class Solution {\n public int minPatches(int[] nums, int n) {\n long miss = 1;\n int i = 0;\n int patches = 0;\n\n while
raviparihar_
NORMAL
2024-06-16T00:36:24.865555+00:00
2024-06-16T14:41:34.763287+00:00
336
false
```\npublic class Solution {\n public int minPatches(int[] nums, int n) {\n long miss = 1;\n int i = 0;\n int patches = 0;\n\n while (miss <= n) {\n if (i < nums.length && nums[i] <= miss) {\n miss += nums[i];\n i++;\n } else {\n ...
2
0
['C', 'Python', 'Java']
2
patching-array
✅ Beginner Friendly with detailed Explanation
beginner-friendly-with-detailed-explanat-t9px
Intuition\nWhen dealing with an array of integers, the goal is to determine the minimum number of patches (additional numbers) required so that every number fro
lebon
NORMAL
2024-06-16T00:24:54.134138+00:00
2024-06-16T00:24:54.134158+00:00
55
false
# Intuition\nWhen dealing with an array of integers, the goal is to determine **the minimum number of patches (_additional numbers_)** required so that every number from 1 to `n` can be formed by the sum of some subset of the array. Initially, it seems feasible to check all combinations, but this would be inefficient. ...
2
0
['Array', 'Greedy', 'Swift']
0
patching-array
Simple Greedy | TypeScript & JavaScript | Beats 100%
simple-greedy-typescript-javascript-beat-p4xo
Intuition\nThe goal is to determine the minimum number of patches needed to ensure that the array can represent any number in the range [1, n] (inclusive). By g
deleted_user
NORMAL
2024-03-24T07:42:36.058146+00:00
2024-03-24T07:42:36.058176+00:00
131
false
# Intuition\nThe goal is to determine the minimum number of patches needed to ensure that the array can represent any number in the range **[1, n]** *(inclusive)*. By greedily selecting the smallest number possible to add to the array at each step, we aim to maximize the range covered by the array without unnecessarily...
2
0
['Greedy', 'TypeScript', 'JavaScript']
1
patching-array
c++ sol | Runtime 4ms | faster than 91.33%
c-sol-runtime-4ms-faster-than-9133-by-ut-81qy
Let\'s consider an example: \n\nLet\'s say the input is nums = [1, 2, 4, 13, 43] and n = 100. We need to ensure that all sums in the range [1,100] are possible.
UttamKumar22
NORMAL
2021-12-16T04:16:32.556814+00:00
2021-12-16T04:17:01.974040+00:00
177
false
**Let\'s consider an example: **\n\nLet\'s say the input is nums = [1, 2, 4, 13, 43] and n = 100. We need to ensure that all sums in the range [1,100] are possible.\nUsing the given numbers 1, 2 and 4, we can already build all sums from 0 to 7, i.e., the range [0,8). But we can\'t build the sum 8, and the next given nu...
2
0
['C']
0
patching-array
Java with explanation
java-with-explanation-by-brucezu-jo2n
\n /*\n Idea:\n Watch the case [1,5,10], n = 20\n let r as the right side number value of continuous sum range [0, r]\n initial r=0; and expected n
brucezu
NORMAL
2021-09-14T02:06:50.136271+00:00
2021-09-14T02:06:50.136318+00:00
243
false
```\n /*\n Idea:\n Watch the case [1,5,10], n = 20\n let r as the right side number value of continuous sum range [0, r]\n initial r=0; and expected next number nums[i] should be <= r+1, else need a patch = r+1;\n if nums[i]==r+1 then r will be r+(r+1)\n if nums[i]< r+1 then r will be r+nums[i];\n ...
2
0
[]
0
patching-array
Very Easy C++ Code (Explained)
very-easy-c-code-explained-by-jontystanl-gzt4
\tSteps:\n Please upvote if you find it helpful .\n\tEvery Interation we can have either of the three conditions:\n\tWe keep interating unitll our reach>=n\n\
jontystanley21
NORMAL
2021-08-30T06:58:26.056383+00:00
2021-08-30T07:01:59.503840+00:00
187
false
# \tSteps:\n Please upvote if you find it helpful .\n\tEvery Interation we can have either of the three conditions:\n\tWe keep interating unitll our **reach>=n**\n\t\n\t1. If my current number is less than or equal to reach, then add that to the reach and move i forward.\n\t2. If my current element, nums[i] is greate...
2
0
[]
0
patching-array
simple java solution
simple-java-solution-by-manishkumarsah-luy5
\nclass Solution {\n public int minPatches(int[] nums, int n) {\n int count = 0;\n int i = 0;\n long reach = 0;\n \n while
manishkumarsah
NORMAL
2021-08-29T14:42:46.413643+00:00
2021-08-29T14:42:46.413698+00:00
114
false
```\nclass Solution {\n public int minPatches(int[] nums, int n) {\n int count = 0;\n int i = 0;\n long reach = 0;\n \n while(reach<n){\n \n if(i>=nums.length){\n reach += reach + 1;\n count++;\n }\n \n ...
2
0
[]
0
patching-array
Python easy to understand solution
python-easy-to-understand-solution-by-so-noff
```\n def minPatches(self, nums: List[int], n: int) -> int:\n prevNum=0\n patches=0\n i=0\n while i=n): return patches\n
sourabhgome
NORMAL
2021-08-29T08:40:47.948455+00:00
2021-08-29T10:02:39.728032+00:00
99
false
```\n def minPatches(self, nums: List[int], n: int) -> int:\n prevNum=0\n patches=0\n i=0\n while i<len(nums):\n num=nums[i]\n if(prevNum>=n): return patches\n if(num<=prevNum+1):\n prevNum=prevNum+num\n i+=1\n else...
2
1
[]
0
patching-array
[Python3] greedy
python3-greedy-by-ye15-awvo
\n\nclass Solution:\n def minPatches(self, nums: List[int], n: int) -> int:\n ans = prefix = k = 0 \n while prefix < n: \n if k < le
ye15
NORMAL
2021-05-07T22:42:28.006153+00:00
2021-05-07T22:42:28.006197+00:00
248
false
\n```\nclass Solution:\n def minPatches(self, nums: List[int], n: int) -> int:\n ans = prefix = k = 0 \n while prefix < n: \n if k < len(nums) and nums[k] <= prefix + 1: \n prefix += nums[k]\n k += 1\n else: \n ans += 1\n ...
2
0
['Python3']
2
patching-array
Java Greedy 100% Faster
java-greedy-100-faster-by-sunnydhotre-qb2h
```\n\tpublic int minPatches(int[] nums, int n) {\n int patches= 0;\n long sum= 0, limit= (long)n;\n for(int i=0; i=limit) break;\n
sunnydhotre
NORMAL
2021-04-03T09:30:44.407155+00:00
2021-04-03T09:48:09.546123+00:00
153
false
```\n\tpublic int minPatches(int[] nums, int n) {\n int patches= 0;\n long sum= 0, limit= (long)n;\n for(int i=0; i<nums.length; i++){\n if(sum>=limit) break;\n if(sum+1<nums[i]){\n i--; patches++;\n sum+= sum+1;\n }else sum+= (long)num...
2
0
[]
0
patching-array
Simple C++ solution
simple-c-solution-by-caspar-chen-hku-fa8t
\nclass Solution {\npublic:\n int minPatches(vector<int>& nums, int n) {\n long long maxReach = 0;\n int ans = 0;\n for(int i = 0; maxRe
caspar-chen-hku
NORMAL
2020-05-25T15:00:26.139923+00:00
2020-05-25T15:00:26.139975+00:00
176
false
```\nclass Solution {\npublic:\n int minPatches(vector<int>& nums, int n) {\n long long maxReach = 0;\n int ans = 0;\n for(int i = 0; maxReach < n;) {\n if(i < nums.size() && nums[i] <= (maxReach + 1)) {\n maxReach = maxReach + nums[i];\n i++;\n ...
2
0
[]
0
patching-array
Short C# Solution
short-c-solution-by-maxpushkarev-y28o
\n public class Solution\n {\n public int MinPatches(int[] nums, int n)\n {\n checked\n {\n (long from,
maxpushkarev
NORMAL
2020-03-29T05:13:06.415714+00:00
2020-03-29T05:13:06.415760+00:00
149
false
```\n public class Solution\n {\n public int MinPatches(int[] nums, int n)\n {\n checked\n {\n (long from, long to) range = (1, 1);\n int res = 0;\n int idx = 0;\n\n while (n >= range.to)\n {\n ...
2
0
[]
0
patching-array
Complete Insightful Explanation | Recursive and Iterative Solutions
complete-insightful-explanation-recursiv-goks
Ignore the provided numbers array for a minute and just consider this:\nIf you wanted to use a numbering system that allowed you to make ANY sum, which numbers
chrisrocco
NORMAL
2019-08-05T19:07:47.882936+00:00
2019-08-05T19:07:47.882970+00:00
211
false
#### Ignore the provided numbers array for a minute and just consider this:\nIf you wanted to use a numbering system that allowed you to make ANY sum, which numbers would you use?\nWe could just use a sequence of ones [1,1,1,1,..,1], but we would need a LOT of them to make big sums (N of them to make all sums up to N)...
2
0
[]
0
patching-array
C++ solution with detailed comments.
c-solution-with-detailed-comments-by-gal-lrkr
\nclass Solution {\npublic:\n int minPatches(vector<int>& nums, int n) {\n long long maxReach = 0;\n int patch = 0;\n int S = nums.size(
galster
NORMAL
2018-10-29T03:48:35.527757+00:00
2018-10-29T03:48:35.527801+00:00
367
false
```\nclass Solution {\npublic:\n int minPatches(vector<int>& nums, int n) {\n long long maxReach = 0;\n int patch = 0;\n int S = nums.size();\n \n // traverse the array while maintaining the maxRead - the furthest number we can generate/\n // from the given numbers\n ...
2
0
[]
2
patching-array
Actually patching
actually-patching-by-stefanpochmann-r0vh
int minPatches(vector<int>& nums, int n) {\n int k = nums.size();\n for (long miss=1, i=0; miss<=n; miss+=nums[i++])\n if (i == nums.si
stefanpochmann
NORMAL
2016-01-27T14:37:04+00:00
2016-01-27T14:37:04+00:00
918
false
int minPatches(vector<int>& nums, int n) {\n int k = nums.size();\n for (long miss=1, i=0; miss<=n; miss+=nums[i++])\n if (i == nums.size() || nums[i] > miss)\n nums.insert(nums.begin()+i, miss);\n return nums.size() - k;\n }\n\nO(k\xb7log(n)) instead of O(k+log(n))...
2
1
[]
0
patching-array
O(k+log(N)) time O(1) space java with explanation
oklogn-time-o1-space-java-with-explanati-6zo9
Iterating the nums[], while keep adding them up, and we are getting a running sum starting from 0. At any position i, if nums[i] > sum+1, them we are sure we ha
chipmonk
NORMAL
2016-01-27T05:27:14+00:00
2016-01-27T05:27:14+00:00
978
false
Iterating the nums[], while keep adding them up, and we are getting a running sum starting from 0. At any position i, if nums[i] > sum+1, them we are sure we have to patch a (sum+1) because all nums before index i can't make sum+1 even adding all of them up, and all nums after index i are all simply too large. Since th...
2
0
['Array', 'Java']
3
patching-array
Why long data type makes a difference
why-long-data-type-makes-a-difference-by-obkz
I tried write my own version of the code after understanding this fancy algorithm, however, i find that declare the variable with 'long' instead of 'int' really
zwsjink
NORMAL
2016-01-28T01:29:29+00:00
2016-01-28T01:29:29+00:00
770
false
I tried write my own version of the code after understanding this fancy algorithm, however, i find that declare the variable with 'long' instead of 'int' really make a difference:\n\n class Solution {\n public:\n int minPatches(vector<int>& nums, int n) {\n int miss_least = 1, i=0, cnt= 0;\n ...
2
0
[]
3
patching-array
7 line JavaScript solution
7-line-javascript-solution-by-linfongi-z95z
function minPatches(nums, n) {\n \tfor (var sum = 0, idx = 0, added = 0; sum < n;) {\n \t\tadded += idx === nums.length || nums[idx] > sum + 1 ? 1 : 0;\n
linfongi
NORMAL
2016-01-31T20:17:58+00:00
2016-01-31T20:17:58+00:00
515
false
function minPatches(nums, n) {\n \tfor (var sum = 0, idx = 0, added = 0; sum < n;) {\n \t\tadded += idx === nums.length || nums[idx] > sum + 1 ? 1 : 0;\n \t\tsum += (nums[idx] || n) > sum + 1 ? sum + 1 : nums[idx++];\n \t}\n \treturn added;\n }
2
0
['JavaScript']
0
patching-array
Simple Python Solution
simple-python-solution-by-dimal97psn-x4y3
def minPatches(self, nums, n):\n ans, nsum = 0, 0\n nums.append(n+1)\n for i in nums:\n num = min(i,n+1)\n while nsum
dimal97psn
NORMAL
2016-02-01T16:26:04+00:00
2016-02-01T16:26:04+00:00
805
false
def minPatches(self, nums, n):\n ans, nsum = 0, 0\n nums.append(n+1)\n for i in nums:\n num = min(i,n+1)\n while nsum + 1 < num:\n nsum += nsum + 1\n ans += 1\n nsum += num\n return ans
2
0
['Python']
0
patching-array
Easy to Understand 1ms Java solution
easy-to-understand-1ms-java-solution-by-ox6wf
public int minPatches(int[] nums, int n) {\n if(n<1) return 0;\n int patch=0;//number of patches\n int covers=0;//the cover range of curren
tlj77
NORMAL
2016-01-29T02:41:49+00:00
2016-01-29T02:41:49+00:00
1,091
false
public int minPatches(int[] nums, int n) {\n if(n<1) return 0;\n int patch=0;//number of patches\n int covers=0;//the cover range of current array\n for(int i=0;i<nums.length;i++){\n if(covers>=n) return patch;\n while(nums[i]-covers>1){\n patch++; /...
2
0
[]
1
patching-array
Javascript solution
javascript-solution-by-coderoath-j3dc
var minPatches = function(nums, n) {\n var covered=1,count=0,i=0;\n //current covered range is [1,covered)\n while(covered<=n){\n
coderoath
NORMAL
2016-02-19T18:43:06+00:00
2016-02-19T18:43:06+00:00
485
false
var minPatches = function(nums, n) {\n var covered=1,count=0,i=0;\n //current covered range is [1,covered)\n while(covered<=n){\n if(i>=nums.length||covered<nums[i]){\n count++;\n covered+=covered;\n }else covered+=nums[i++];\n }\n ...
2
0
['JavaScript']
0
patching-array
C#
c-by-adchoudhary-qux4
Code
adchoudhary
NORMAL
2025-02-20T06:37:54.204870+00:00
2025-02-20T06:37:54.204870+00:00
7
false
# Code ```csharp [] public class Solution { public int MinPatches(int[] nums, int n) { long max = 0, numsAdded = 0; foreach (var num in nums) { while (num > max + 1) // O(LogT) { max += max + 1; // add no which is 1 greater than last max number we can create till now nu...
1
0
['C#']
0
check-if-digits-are-equal-in-string-after-operations-i
✅2 Method's ||Strings||🌟JAVA||🧑‍💻 BEGINNER FREINDLY||C++||Python
2-methods-stringsjava-beginner-freindlyc-94g9
Approach1: Brute Force1.Loop Until Two Digits: Use a loop to keep processing the string until its length is reduced to 2. 2.Calculate New Digits: For each pair
Varma5247
NORMAL
2025-02-23T04:49:12.431905+00:00
2025-03-03T14:15:57.192407+00:00
2,781
false
# Approach1: Brute Force <!-- Describe your approach to solving the problem. --> 1.**Loop Until Two Digits:** Use a loop to keep processing the string until its length is reduced to ```2```. 2.**Calculate New Digits:** For each pair of consecutive digits, calculate the new digit as ```(firstDigit + secondDigit) % 10...
15
3
['Hash Table', 'String', 'Python', 'C++', 'Java']
6
check-if-digits-are-equal-in-string-after-operations-i
Java Solution || 6ms
java-solution-6ms-by-dsuryaprakash89-3zuw
Approach Start with a string sb simulate till the length of string is greater than 2 Start with empty string nextsb get the 1st 2 characters compute the modulo
dsuryaprakash89
NORMAL
2025-02-23T04:30:11.814696+00:00
2025-02-23T04:30:11.814696+00:00
894
false
# Approach - Start with a string sb - simulate till the length of string is greater than 2 - Start with empty string nextsb - get the 1st 2 characters - compute the modulo - append to nextsb - this nextsb is now the string sb - Return true if char at index 0 is equal to char at index 1 - else return f...
5
0
['String', 'Java']
1
check-if-digits-are-equal-in-string-after-operations-i
Python Elegant & Short | Simulation
python-elegant-short-simulation-by-kyryl-t6lt
Complexity Time complexity: O(n2) Space complexity: O(n) Code
Kyrylo-Ktl
NORMAL
2025-03-06T08:24:01.164552+00:00
2025-03-06T08:24:01.164552+00:00
558
false
# Complexity - Time complexity: $$O(n^2)$$ - Space complexity: $$O(n)$$ # Code ```python3 [] class Solution: def hasSameDigits(self, s: str) -> bool: digits = [int(d) for d in s] while len(digits) > 2: digits = [(a + b) % 10 for a, b in pairwise(digits)] one, two = digits ...
4
0
['String', 'Simulation', 'Python', 'Python3']
1
check-if-digits-are-equal-in-string-after-operations-i
Two Lines Only
two-lines-only-by-charnavoki-unr8
null
charnavoki
NORMAL
2025-02-23T11:03:35.248294+00:00
2025-02-23T11:03:35.248294+00:00
334
false
```javascript [] const perform = ([a, ...b]) => b.map((x) => ([a, x] = [x, a], (+x + +a) % 10)); const hasSameDigits = f = s => s.length < 3 ? s[0] === s[1] : f(perform(s)); ```
4
0
['JavaScript']
1
check-if-digits-are-equal-in-string-after-operations-i
simple solutions
simple-solutions-by-vinay_kumar_swami-ktl6
IntuitionApproachComplexity Time complexity: Space complexity: Code
vinay_kumar_swami
NORMAL
2025-02-23T04:04:07.875057+00:00
2025-02-23T04:04:07.875057+00:00
1,076
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 `...
4
0
['C++']
2
check-if-digits-are-equal-in-string-after-operations-i
🌟 Simplest Solution Python3 💯🔥🗿
simplest-solution-python3-by-emmanuel011-ohdc
Code
emmanuel011
NORMAL
2025-02-25T20:23:20.366559+00:00
2025-02-25T20:23:20.366559+00:00
535
false
# Code ```python3 [] class Solution: def hasSameDigits(self, s: str) -> bool: my_list = list(map(lambda x: int(x), s)) for _ in range(len(s) - 2): my_list = [(my_list[i] + my_list[i + 1]) % 10 for i in range(len(my_list) - 1)] return my_list[0] == my_list[1] ```
3
0
['Python3']
0
check-if-digits-are-equal-in-string-after-operations-i
🔥 100% Beast Mode Activated! 🚀 Ultra-Efficient Java Solution
100-beast-mode-activated-ultra-efficient-ecz9
IntuitionImagine you are manually performing this task with a pen and paper. How would you do it?1️⃣ Look at the first two digits → Add them and write down only
Apoorv_jain24
NORMAL
2025-02-23T05:23:16.743642+00:00
2025-02-23T05:23:16.743642+00:00
94
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> Imagine you are manually performing this task with a pen and paper. How would you do it? 1️⃣ Look at the first two digits → Add them and write down only the last digit (ignore carry). 2️⃣ Move to the next pair → Repeat the addition and rec...
3
0
['Java']
1
check-if-digits-are-equal-in-string-after-operations-i
✅ ⟣ Java Solution ⟢
java-solution-by-harsh__005-s077
Code
Harsh__005
NORMAL
2025-02-23T04:02:53.607487+00:00
2025-02-23T04:02:53.607487+00:00
321
false
# Code ```java [] class Solution { public boolean hasSameDigits(String s) { int n = s.length(); while(n > 2) { String nstr = ""; for(int i=1; i<n; i++) { int next = ((s.charAt(i)-'0')+(s.charAt(i-1)-'0')) % 10; nstr += next; } ...
3
1
['Java']
1
check-if-digits-are-equal-in-string-after-operations-i
✅ Check If Digits Are Equal || C++ ⚡ JAVA || Beginner Friendly 🔥🔥
check-if-digits-are-equal-c-java-beginne-z330
IntuitionThe problem involves iteratively transforming a string of digits by replacing each pair of adjacent digits with their sum modulo 10. This process conti
Devraj_Shirsath_18
NORMAL
2025-02-23T04:01:34.688829+00:00
2025-02-23T04:17:45.477973+00:00
527
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> The problem involves iteratively transforming a string of digits by replacing each pair of adjacent digits with their sum modulo 10. This process continues until the string is reduced to two characters, at which point we check if they are t...
3
0
['String', 'C++', 'Java']
0
check-if-digits-are-equal-in-string-after-operations-i
Trading Space for Speed 🚀 – Even Beginners Can Understand! | Python 3
trading-space-for-speed-even-beginners-c-ayji
Convert string to listCode
thiyophin22
NORMAL
2025-02-25T19:30:34.763619+00:00
2025-02-25T19:30:34.763619+00:00
349
false
Convert string to list # Code ```python3 [] class Solution: def hasSameDigits(self, s: str) -> bool: s = list(s) temp = s while len(s) != 2: size = len(s) s = [] for x in range(size-1): s.append(str(int(int(temp[x]) + int(temp[x+1])) % 10...
2
0
['Python3']
0
check-if-digits-are-equal-in-string-after-operations-i
005. done!
005-done-by-ritikaslaptop-p5cm
Intuitionsimple while loop⭐python allows returning boolean expressions directly instead of specifying !i.e this is unnecessary ⬇️Code
ritikaslaptop
NORMAL
2025-02-24T10:40:07.538949+00:00
2025-02-24T10:40:07.538949+00:00
185
false
# Intuition simple while loop ⭐python allows returning boolean expressions directly instead of specifying ! i.e this is unnecessary ⬇️ ``` if s[0] == s[1]: return True else: return False ``` # Code ```python3 [] class Solution: def hasSameDigits(self, s: str) -> bool: while len(s) > 2: ...
2
0
['Python3']
1
check-if-digits-are-equal-in-string-after-operations-i
Iterative Modulo Reduction for Equal Digits Check
iterative-modulo-reduction-for-equal-dig-5ics
IntuitionThe problem requires repeatedly applying an operation to a string of digits until only two digits remain. The operation involves replacing each pair of
x7Fg9_K2pLm4nQwR8sT3vYz5bDcE6h
NORMAL
2025-02-23T18:26:34.056768+00:00
2025-02-23T18:26:34.056768+00:00
123
false
# Intuition The problem requires repeatedly applying an operation to a string of digits until only two digits remain. The operation involves replacing each pair of consecutive digits with their sum modulo 10. The goal is to determine if the final two digits are the same. # Approach 1. Iterative Reduction: Continuously...
2
0
['C++']
0
check-if-digits-are-equal-in-string-after-operations-i
3ms Runtime || BEATS 100% || C++
3ms-runtime-beats-100-c-by-kartik_7-p19g
IntuitionKeep adding adjacent digits and taking their last digit until we either find same adjacent digits or end up with a single digit.Approach While string l
Kartik_7
NORMAL
2025-02-23T12:23:46.392129+00:00
2025-02-23T12:23:46.392129+00:00
57
false
# Intuition Keep adding adjacent digits and taking their last digit until we either find same adjacent digits or end up with a single digit. # Approach 1. While string length > 1: - For length 2: check if both digits same - Add adjacent digits, keep last digit only - Form new string with these sums - Repeat until no...
2
0
['Hash Table', 'String', 'C++']
0
check-if-digits-are-equal-in-string-after-operations-i
3461. Check If Digits Are Equal in String After Operations I
3461-check-if-digits-are-equal-in-string-pk4a
Code
PanditJI20
NORMAL
2025-02-23T06:01:52.881388+00:00
2025-02-23T06:01:52.881388+00:00
385
false
# Code ```python3 [] class Solution: def hasSameDigits(self, s: str) -> bool: arr =[] arr.append(s) while len(arr[-1])!=2: res = '' for i in range(len(arr[-1])-1): res += str((int(arr[-1][i]) + int(arr[-1][i+1]))%10) arr.append(res) ...
2
0
['Python', 'Python3']
0
check-if-digits-are-equal-in-string-after-operations-i
Easy Beginner friendly C++ || Beats 90% +
easy-beginner-friendly-c-beats-90-by-nik-g6o5
IntuitionApproachComplexity Time complexity: Space complexity: Code
Nikhilk18
NORMAL
2025-02-23T04:46:35.375126+00:00
2025-02-23T04:46:35.375126+00:00
111
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 `...
2
0
['C++']
0
check-if-digits-are-equal-in-string-after-operations-i
🔢✨✅ Check If Digits Become Equal After Operations 🔁 | C++ 🧮 | Brute Force Approach 💪
check-if-digits-become-equal-after-opera-qg5x
🧠 Intuition The goal is to check whether a given string of digits can be reduced to a 2-digit string where both digits are the same. At each step, you generate
manishkumar92913
NORMAL
2025-02-23T04:41:54.921066+00:00
2025-02-23T04:41:54.921066+00:00
57
false
# 🧠 Intuition <!-- Describe your first thoughts on how to solve this problem. --> - The goal is to check whether a given string of digits can be reduced to a 2-digit string where both digits are the same. At each step, you generate a new string by summing adjacent pairs of digits (mod 10) until the length of the strin...
2
0
['C++']
0
check-if-digits-are-equal-in-string-after-operations-i
simplest solution | c++
simplest-solution-c-by-hriii11-vtfh
IntuitionThe problem involves repeatedly reducing a string by summing consecutive digits and taking only the last digit (mod 10). The process continues until th
Hriii11
NORMAL
2025-02-23T04:09:48.950048+00:00
2025-02-23T04:09:48.950048+00:00
31
false
# Intuition The problem involves repeatedly reducing a string by summing consecutive digits and taking only the last digit (mod 10). The process continues until the string is reduced to two characters, at which point we check if they are equal. # Approach 1. Start with a given numeric string s. 2. Continuously reduce ...
2
0
['C++']
0
check-if-digits-are-equal-in-string-after-operations-i
🔢 Check if a Number String Reduces to Two Same Digits
check-if-a-number-string-reduces-to-two-4uwf9
✅ IntuitionThe problem requires checking whether a string of digits, through a series of transformations, reduces to two identical digits. In each transformatio
solaimuthu
NORMAL
2025-03-31T20:33:33.240576+00:00
2025-03-31T20:33:33.240576+00:00
45
false
## ✅ **Intuition** The problem requires checking whether a string of digits, through a series of transformations, reduces to two identical digits. - In each transformation: - For every adjacent pair of digits: - Add them together. - Append the last digit of the sum (using modulo 10) to form a new string. - ...
1
0
['Java']
0
check-if-digits-are-equal-in-string-after-operations-i
Efficient Digit Compression and Comparison in Strings
efficient-digit-compression-and-comparis-xy01
🔥 IntuitionThe goal is to repeatedly reduce the string by summing adjacent digits and appending the result modulo 10 until the string length becomes 2 or less.
vishwajeetwalekar037
NORMAL
2025-03-25T07:14:56.551756+00:00
2025-03-25T07:14:56.551756+00:00
23
false
### 🔥 **Intuition** <!-- Describe your first thoughts on how to solve this problem. --> The goal is to repeatedly **reduce the string** by summing adjacent digits and appending the result modulo `10` until the string length becomes **2 or less**. - If the resulting string has exactly **two equal digits**, return `t...
1
0
['Java']
0
check-if-digits-are-equal-in-string-after-operations-i
Clean solution📈 || Brute force
clean-solution-brute-force-by-ashish-joh-yis7
Code
ashish-john
NORMAL
2025-03-22T07:13:43.250947+00:00
2025-03-22T07:13:43.250947+00:00
25
false
# Code ```javascript [] /** * @param {string} s * @return {boolean} */ var hasSameDigits = function(s) { while (s.length > 2) { let result = ''; for (let i = 0; i < s.length - 1; i++) { let sum = (s[i] - '0') + (s[i + 1] - '0'); result += (sum % 10).toString(); ...
1
0
['JavaScript']
0
check-if-digits-are-equal-in-string-after-operations-i
python3 solution beats 95.15%
python3-solution-beats-9515-by-nullx37-0b75
IntuitionPerform operations till we shrink the list's length to 2ApproachStack based approachComplexity Time complexity: Space complexity: Code
nullx37
NORMAL
2025-03-19T05:32:32.113860+00:00
2025-03-19T05:32:32.113860+00:00
79
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> Perform operations till we shrink the list's length to 2 # Approach <!-- Describe your approach to solving the problem. --> Stack based approach # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> Clos...
1
0
['Array', 'Python3']
0
check-if-digits-are-equal-in-string-after-operations-i
Beats 100% Easy Java Code to Understand Line to Line Explanation
beats-100-easy-java-code-to-understand-l-7d2b
Code
adityaa_panwar
NORMAL
2025-03-02T03:38:50.372200+00:00
2025-03-02T03:38:50.372200+00:00
51
false
# Code ```java [] class Solution { public boolean hasSameDigits(String s) { int n=s.length(); int[] digit=new int[n]; for(int i=0;i<n;i++){ digit[i]=s.charAt(i)-'0'; //it get the Digit Value as charAt(i)-'0 = '3'-'0' = 51-48 = 3 } while(n>2){ //performs the ope...
1
0
['Math', 'String', 'String Matching', 'Number Theory', 'Java']
0
check-if-digits-are-equal-in-string-after-operations-i
Weekly Contest 438 Q#1
weekly-contest-438-q1-by-xcwrebnifv-m0lz
IntuitionThe intuition behind this approach is straightforward—we can directly follow the given instructions to arrive at the optimal solution.Approach Perform
xcwrEbNifv
NORMAL
2025-03-01T07:43:27.457528+00:00
2025-03-01T07:43:27.457528+00:00
69
false
# Intuition The intuition behind this approach is straightforward—we can directly follow the given instructions to arrive at the optimal solution. # Approach 1. Perform the given operations iteratively, updating all elements up to `lenth - 1`. 2. After each iteration, the effective length of the array decreases by one...
1
0
['Java']
1
check-if-digits-are-equal-in-string-after-operations-i
🥇 Beat 100%
beat-100-by-nkoruts-2sty
Code
nkoruts
NORMAL
2025-02-26T23:21:17.192829+00:00
2025-02-26T23:21:17.192829+00:00
46
false
# Code ```swift [] class Solution { func hasSameDigits(_ s: String) -> Bool { var array = s.compactMap(\.wholeNumberValue) while array.count > 2 { for index in 1..<array.count { array[index - 1] = (array[index - 1] + array[index]) % 10 } array.remo...
1
0
['Swift']
0
check-if-digits-are-equal-in-string-after-operations-i
EASY C++
easy-c-by-hnmali-9d18
Code
hnmali
NORMAL
2025-02-25T18:12:24.001734+00:00
2025-02-25T18:12:24.001734+00:00
45
false
# Code ```cpp [] class Solution { public: bool hasSameDigits(string s) { while(s.size() > 2) { for(int i = 0; i < s.size()-1; i++) { int temp = s[i]+s[i+1]-'0'-'0'; temp %= 10; s[i] = temp + '0'; } s.pop_back(); } ...
1
0
['Math', 'String', 'Simulation', 'C++']
0
check-if-digits-are-equal-in-string-after-operations-i
Beats 56% | Python 3
beats-56-python-3-by-alpha2404-f1yv
Please UpvoteCode
Alpha2404
NORMAL
2025-02-25T03:36:42.278456+00:00
2025-02-25T03:36:42.278456+00:00
90
false
# Please Upvote # Code ```python3 [] class Solution: def hasSameDigits(self, s: str) -> bool: def operate(s): temp = "" for i in range(len(s)-1): temp+=str((int(s[i])+int(s[i+1]))%10) return temp while len(s)!=2: s = operate(s) ...
1
0
['Python3']
0
check-if-digits-are-equal-in-string-after-operations-i
Easy In-place C++ Solution | No Extra Space/Memory Used | Beats 100% in Time and Space
easy-in-place-c-solution-no-extra-spacem-wa1q
IntuitionThe in-place modification works by overwriting each pair's left position with their sum modulo 10, while the inner loop processes pairs from left to ri
pratiiik_p
NORMAL
2025-02-24T18:43:16.971760+00:00
2025-02-26T14:17:13.178837+00:00
47
false
# Intuition The in-place modification works by overwriting each pair's left position with their sum modulo 10, while the inner loop processes pairs from left to right. Since each step uses the original right digit (not yet overwritten in this iteration), it safely updates positions without affecting subsequent pairs in...
1
0
['C++']
0
check-if-digits-are-equal-in-string-after-operations-i
Best and Easiest Approach to solve this question with 100% beats (GUARANTEED)
best-and-easiest-approach-to-solve-this-jtarr
IntuitionApproachComplexity Time complexity: Space complexity: Code
HARDIK_ARORA_16
NORMAL
2025-02-24T17:07:04.521419+00:00
2025-02-24T17:07:04.521419+00:00
10
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 `...
1
0
['Python3']
0
check-if-digits-are-equal-in-string-after-operations-i
Easy Solution
easy-solution-by-kundankumar95-gi2l
IntuitionApproachComplexity Time complexity: Space complexity: Code
kundankumar95
NORMAL
2025-02-24T17:06:30.719320+00:00
2025-02-24T17:06:30.719320+00:00
22
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 `...
1
0
['C++']
0
check-if-digits-are-equal-in-string-after-operations-i
Simple Java Solution with Detail Explanation
simple-java-solution-with-detail-explana-ap0e
IntuitionThe problem requires checking whether a given string of digits can be reduced to two equal numbers by repeatedly summing adjacent digits modulo 10.The
tejassinkar24
NORMAL
2025-02-24T13:41:27.618811+00:00
2025-02-24T13:41:27.618811+00:00
4
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> The problem requires checking whether a given string of digits can be reduced to two equal numbers by repeatedly summing adjacent digits modulo 10. The key observation is that at each step, the array size decreases by 1, and the elements a...
1
0
['Java']
0
check-if-digits-are-equal-in-string-after-operations-i
100% Affective CPP Solution
100-affective-cpp-solution-by-sanchit812-bbb7
IntuitionApproachComplexity Time complexity:O(n^2) Space complexity:O(1) Code
Sanchit8125
NORMAL
2025-02-24T12:03:40.920522+00:00
2025-02-24T12:03:40.920522+00:00
33
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: O(n^2) - Space complexity: O(1) # Code ```cpp [] class Solution { public: bool hasSameDigits(string s) { if(s.length()<3) ret...
1
0
['C++']
0
check-if-digits-are-equal-in-string-after-operations-i
Easy to understand , Beats 100 % both memory and time complexity
easy-to-understand-beats-100-both-memory-7zpe
IntuitionApproachComplexity Time complexity:O(N) Space complexity:O(N) Code
SHIJITH7498
NORMAL
2025-02-24T07:29:40.205418+00:00
2025-02-24T07:29:40.205418+00:00
98
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity:O(N) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity:O(N) <!-- Add your space complexity here, e.g. $$O(n)$$ --> ...
1
0
['Python3']
0
check-if-digits-are-equal-in-string-after-operations-i
Simple CPP Solution
simple-cpp-solution-by-deva766825_gupta-2lcp
Code
deva766825_gupta
NORMAL
2025-02-24T04:38:53.197800+00:00
2025-02-24T04:38:53.197800+00:00
7
false
# Code ```cpp [] class Solution { public: bool hasSameDigits(string s) { while(s.length()>2) { string curr=""; for(int i=0;i<s.length()-1;i++){ int sum=(s[i]-'0'+s[i+1]-'0')%10; curr+=(sum+'0'); } ...
1
0
['C++']
0
check-if-digits-are-equal-in-string-after-operations-i
Easy Solution using QUEUE | C++
easy-solution-using-queue-c-by-rahmankha-t1a0
IntuitionThe idea is inspired by pairwise reduction, where at each step, two adjacent numbers are summed, and only the last digit (% 10) is considered.The proce
Rahmankhan3
NORMAL
2025-02-23T20:03:54.851057+00:00
2025-02-23T20:03:54.851057+00:00
27
false
# Intuition The idea is inspired by pairwise reduction, where at each step, two adjacent numbers are summed, and only the last digit (% 10) is considered. The process continues until only two digits remain. Finally, we compare the last two digits to determine if they are the same. # Approach Initialize a queue: Convert...
1
0
['Queue', 'C++']
0
check-if-digits-are-equal-in-string-after-operations-i
Best Solution 👌👇
best-solution-by-ram_saketh-2xrb
Complexity Time complexity:O(n^2) Space complexity:O(n) Code
Ram_Saketh
NORMAL
2025-02-23T19:49:38.287074+00:00
2025-02-23T19:49:38.287074+00:00
11
false
# Complexity - Time complexity:O(n^2) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity:O(n) <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code ```java [] class Solution { public boolean hasSameDigits(String s) { if (s.length() < 2) return true; while(s....
1
0
['String', 'String Matching', 'Java']
0
check-if-digits-are-equal-in-string-after-operations-i
E
e-by-runningfalcon-c8vd
IntuitionApproachComplexity Time complexity: Space complexity: Code
runningfalcon
NORMAL
2025-02-23T18:43:14.911628+00:00
2025-02-23T18:43:14.911628+00:00
12
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 `...
1
0
['Java']
0
check-if-digits-are-equal-in-string-after-operations-i
AAAAAAAAAAAAAAAAAAAAAAAAAAA
aaaaaaaaaaaaaaaaaaaaaaaaaaa-by-danisdeve-imzh
Code
DanisDeveloper
NORMAL
2025-02-23T17:31:01.678725+00:00
2025-02-23T17:31:01.678725+00:00
15
false
# Code ```kotlin [] class Solution { fun hasSameDigits(s: String): Boolean { var current = s.toMutableList() while (true) { val temp = mutableListOf<Char>() for (i in 0 until current.size - 1) { val sum = (current[i].code + current[i + 1].code - '0'.code * 2...
1
0
['Kotlin']
0
check-if-digits-are-equal-in-string-after-operations-i
C++ [Easy] 🔥🎊
c-easy-by-varuntyagig-w9ua
Code
varuntyagig
NORMAL
2025-02-23T17:08:11.071483+00:00
2025-02-23T17:08:11.071483+00:00
26
false
# Code ```cpp [] class Solution { public: bool hasSameDigits(string s) { while (true) { string str = ""; for (int i = 0; i < s.length() - 1; ++i) { str += (((s[i] + s[i + 1]) % 10) + '0'); } if (str.length() == 2) { if (str[0] ...
1
0
['String', 'C++']
0
check-if-digits-are-equal-in-string-after-operations-i
it's work
its-work-by-bhav5sh-gc05
IntuitionApproachComplexity Time complexity: Space complexity: Code
Bhav5sh
NORMAL
2025-02-23T13:01:42.886426+00:00
2025-02-23T13:01:42.886426+00:00
61
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 `...
1
0
['Python3']
0
check-if-digits-are-equal-in-string-after-operations-i
0ms 100% infinite harmony check
0ms-100-by-michelusa-fbd8
ApproachThe core idea revolves around iterative digit reduction. We start with a string of digits and repeatedly transform it by processing adjacent pairs.The c
michelusa
NORMAL
2025-02-23T11:42:18.944068+00:00
2025-02-23T12:03:55.780937+00:00
28
false
**Approach** The core idea revolves around iterative digit reduction. We start with a string of digits and repeatedly transform it by processing adjacent pairs. The code enters an infinite for (;;) loop, designed for repeated transformation until a termination condition is met: - Adjacent Digit Summation - Terminatio...
1
0
['C++']
0
check-if-digits-are-equal-in-string-after-operations-i
Simple java solution- O(log(n))
simple-java-solution-ologn-by-swapit-tl5p
Code
swapit
NORMAL
2025-02-23T08:32:26.336774+00:00
2025-02-23T08:32:26.336774+00:00
45
false
# Code ```java [] class Solution { public boolean hasSameDigits(String s) { while (s.length()>2) { String str = ""; for (int i = 0; i < s.length() - 1; i++) { int num = Character.getNumericValue(s.charAt(i)) + Character.getNumericValue(s.charAt(i + 1)); str += num%10; } s = str; } ret...
1
0
['Java']
0
check-if-digits-are-equal-in-string-after-operations-i
Easy and simple explanation in python 🚀🚀
easy-and-simple-explanation-in-python-by-vucv
IntuitionWe repeatedly replace each pair of adjacent digits with their sum modulo 10. This reduces the length of the string step by step until only two digits r
harshit197
NORMAL
2025-02-23T08:27:37.214833+00:00
2025-02-23T08:27:37.214833+00:00
27
false
# Intuition We repeatedly replace each pair of adjacent digits with their sum modulo 10. This reduces the length of the string step by step until only two digits remain. If the final two digits are the same, we return `True`; otherwise, we return `False`. # Approach 1. Convert the given string `s` into a new string wh...
1
0
['Math', 'String', 'String Matching', 'Python3']
0
check-if-digits-are-equal-in-string-after-operations-i
Recursive ✅ - Beats 100% - Python/Java/C++
recursive-beats-100-pythonjavac-by-cryan-kvl8
IntuitionApproachComplexity Time complexity: Space complexity: Code
cryandrich
NORMAL
2025-02-23T08:04:04.275920+00:00
2025-02-23T08:04:04.275920+00:00
9
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 `...
1
0
['C++', 'Java', 'Python3']
0
check-if-digits-are-equal-in-string-after-operations-i
easy cpp solution to understand
easy-cpp-solution-to-understand-by-prati-00g5
IntuitionApproachComplexity Time complexity: Space complexity: Code
pratik5722
NORMAL
2025-02-23T08:01:25.693849+00:00
2025-02-23T08:01:25.693849+00:00
9
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 `...
1
0
['C++']
0
check-if-digits-are-equal-in-string-after-operations-i
Repeated Digit Sum Check || String Comparison || Beats 100.00%
repeated-digit-sum-check-string-comparis-spcz
IntuitionThe problem asks to determine if after repeatedly summing adjacent digits modulo 10, the final two digits are the same. This suggests a simulation appr
MLTaza
NORMAL
2025-02-23T07:05:45.210686+00:00
2025-02-23T07:05:45.210686+00:00
20
false
# Intuition The problem asks to determine if after repeatedly summing adjacent digits modulo 10, the final two digits are the same. This suggests a simulation approach where we perform the summing operation until we are left with a string of length 2, and then check if the two digits are equal. # Approach 1. Iterate ...
1
0
['Java']
0
check-if-digits-are-equal-in-string-after-operations-i
"Recursive Digit Reduction to Check for Uniform Digits"
recursive-digit-reduction-to-check-for-u-ek1j
IntuitionFirst calculating the first operation and then recursively calling the same function with the string we get from the first operation. And recursively c
TECH_AJAY
NORMAL
2025-02-23T07:00:38.698473+00:00
2025-02-23T07:00:38.698473+00:00
51
false
# Intuition First calculating the first operation and then recursively calling the same function with the string we get from the first operation. And recursively calling the function until we get the two digits. # Approach The approach works by reducing the string of digits recursively. For every string: It iterates ...
1
0
['String', 'Recursion', 'Java']
1
check-if-digits-are-equal-in-string-after-operations-i
<<BEAT 100% SOLUTIONS || BEGINNER FRIENDLY SOLUTIONS>>
beat-100-solutions-beginner-friendly-sol-77k3
PLEASE UPVOTE MECode
Dakshesh_vyas123
NORMAL
2025-02-23T05:52:57.080970+00:00
2025-02-23T05:52:57.080970+00:00
33
false
# **PLEASE UPVOTE ME** # Code ```cpp [] class Solution { public: bool hasSameDigits(string s) { while(s.size()>2){ string a; for(int i=0;i<s.size()-1;i++){ int x=((s[i]-'0')+(s[i+1]-'0'))%10; a.push_back(x); } s=a; } ...
1
0
['C++']
0
check-if-digits-are-equal-in-string-after-operations-i
short and simple
short-and-simple-by-tavish_golcha-1cys
IntuitionApproachComplexity Time complexity: Space complexity: Code
TAVISH_golcha
NORMAL
2025-02-23T05:46:21.874586+00:00
2025-02-23T05:46:21.874586+00:00
8
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 `...
1
0
['C++']
0
check-if-digits-are-equal-in-string-after-operations-i
3461. Check If Digits Are Equal in String After Operations I - || Easy Python || List || String ||
3461-check-if-digits-are-equal-in-string-095d
IntuitionThe goal is to iteratively transform the input string by summing adjacent digits and taking the last digit of the sum (modulo 10). This process continu
PANDITVIPUL05
NORMAL
2025-02-23T05:38:44.909398+00:00
2025-02-23T05:38:44.909398+00:00
54
false
# Intuition The goal is to iteratively transform the input string by summing adjacent digits and taking the last digit of the sum (modulo 10). This process continues until only two digits remain. If the resulting two digits are the same, return True; otherwise, return False. <!-- Describe your first thoughts on how to ...
1
0
['Python3']
0
check-if-digits-are-equal-in-string-after-operations-i
Python3 || 4 lines, pairwise and map || T/S: 98% / 95%
python3-5-lines-pairwise-and-map-ts-x-ms-bglp
Here's the plan: We map the string of digits to a list of single digit integers. We use pairwise to determine the pair sums, and we use iteration to continue
Spaulding_
NORMAL
2025-02-23T05:16:25.460937+00:00
2025-03-17T20:42:44.039971+00:00
33
false
Here's the plan: 1. We map the string of digits to a list of single digit integers. 2. We use `pairwise` to determine the pair sums, and we use iteration to continue the process until the length of the list is exactly two. 3. We check whether the two list elements are equal. ```python3 [] class Solution: def hasSa...
1
0
['Python3']
0
check-if-digits-are-equal-in-string-after-operations-i
Most easy approach using char->int approach
most-easy-approach-using-char-int-approa-a0jo
IntuitionApproachComplexity Time complexity: Space complexity: Code
Eclipse27
NORMAL
2025-02-23T04:39:48.962093+00:00
2025-02-23T04:39:48.962093+00:00
20
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 `...
1
0
['Java']
0
check-if-digits-are-equal-in-string-after-operations-i
Easy JAVA Solution || Beats 100%
easy-java-solution-beats-100-by-harsh123-c4oc
IntuitionApproachComplexity Time complexity: Space complexity: Code
Harsh123009
NORMAL
2025-02-23T04:35:43.656629+00:00
2025-02-23T04:35:43.656629+00:00
24
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 `...
1
0
['Java']
0
check-if-digits-are-equal-in-string-after-operations-i
Python solution
python-solution-by-kashsuks-ceht
Code
kashsuks
NORMAL
2025-02-23T04:23:15.526555+00:00
2025-02-23T04:23:15.526555+00:00
12
false
# Code ```python3 [] class Solution: def hasSameDigits(self, s: str) -> bool: while len(s) > 2: s = ''.join(str((int(s[i]) + int(s[i+1])) % 10) for i in range(len(s) - 1)) return s[0] == s[1] ```
1
0
['Python3']
0
check-if-digits-are-equal-in-string-after-operations-i
Simple C++ Solution | Weekly Contest 438 | String
simple-c-solution-weekly-contest-438-str-fh8v
SolutionComplexity Time complexity: O(n2) Space complexity: O(n) Code
ipriyanshi
NORMAL
2025-02-23T04:22:57.469778+00:00
2025-02-23T04:22:57.469778+00:00
30
false
# Solution https://youtu.be/V98ueQ4zVkg # Complexity - Time complexity: $$O(n^2)$$ - Space complexity: $$O(n)$$ # Code ```cpp [] class Solution { public: bool hasSameDigits(string s) { string temp = ""; while(s.length() > 2){ for(int i = 0; i < s.length()-1; i++){ temp...
1
0
['C++']
0
check-if-digits-are-equal-in-string-after-operations-i
[PYTHON] ** 6 Lines of Codes Beats 100% **
python-6-lines-of-codes-beats-100-by-ant-l0p9
IntuitionAdd the new elements to the end and remove old digits.Complexity Time complexity:O(n) Space complexity:O(1) Code
anthony-le-vn
NORMAL
2025-02-23T04:21:32.978873+00:00
2025-02-23T04:21:32.978873+00:00
56
false
# Intuition Add the new elements to the end and remove old digits. # Complexity - Time complexity: $$O(n)$$ - Space complexity: $$O(1)$$ # Code ```python [] class Solution(object): def hasSameDigits(self, s): """ :type s: str :rtype: bool """ while len(s) > 2: ...
1
0
['Recursion', 'Python']
0
check-if-digits-are-equal-in-string-after-operations-i
Simple C++ Solution | Weekly Contest 438 | String
simple-c-solution-weekly-contest-438-str-9253
SolutionComplexity Time complexity: O(n2) Space complexity: O(n) Code
iAmPriyanshi1708
NORMAL
2025-02-23T04:21:10.686623+00:00
2025-02-23T04:21:10.686623+00:00
16
false
# Solution # Complexity - Time complexity: $$O(n^2)$$ - Space complexity: $$O(n)$$ # Code ```cpp [] class Solution { public: bool hasSameDigits(string s) { string temp = ""; while(s.length() > 2){ for(int i = 0; i < s.length()-1; i++){ temp.push_back((s[i]+s[i+1])%10);...
1
0
['C++']
0
check-if-digits-are-equal-in-string-after-operations-i
Simple Python Solution, beat 100% ✅
simple-python-solution-beat-100-by-sara5-4jx2
Code
sara533
NORMAL
2025-02-23T04:17:04.652225+00:00
2025-02-23T04:17:04.652225+00:00
40
false
# Code ```python3 [] class Solution: def compute(self, s: str) -> str: res = "" for i in range(len(s) - 1): digit = (int(s[i]) + int(s[i+1])) % 10 res += str(digit) return res def hasSameDigits(self, s: str) -> bool: res = s while len(res) > 2: ...
1
0
['Python3']
0
check-if-digits-are-equal-in-string-after-operations-i
Simple Solution
simple-solution-by-ankith_kumar-qzpk
Complexity Time complexity: O(N^2) Space complexity: O(N) Code
Ankith_Kumar
NORMAL
2025-02-23T04:06:14.902167+00:00
2025-02-23T04:06:14.902167+00:00
8
false
# Complexity - Time complexity: O(N^2) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: O(N) <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code ```java [] class Solution { public boolean hasSameDigits(String s) { StringBuilder str = new StringBuilder(s); while...
1
0
['Java']
0
check-if-digits-are-equal-in-string-after-operations-i
✅🔥Easy to Understand | C++ Code
easy-to-understand-c-code-by-minavkaria-hmd0
ApproachLoop and replace the string till the size of p not becomes 2Code
MinavKaria
NORMAL
2025-02-23T04:02:27.144335+00:00
2025-02-23T04:02:27.144335+00:00
34
false
# Approach <!-- Describe your approach to solving the problem. --> Loop and replace the string till the size of p not becomes 2 # Code ```cpp [] class Solution { public: bool hasSameDigits(string s) { int n = s.size(); int tk = n - 1; string p = s; while (p.size() != 2) { ...
1
0
['C++']
0
check-if-digits-are-equal-in-string-after-operations-i
java solution
java-solution-by-mdshoaib6360-q03z
Complexity Time complexity:0(n) Space complexity:0(n) Code
mdshoaib6360
NORMAL
2025-02-23T04:02:12.997851+00:00
2025-02-23T04:02:12.997851+00:00
24
false
# Complexity - Time complexity:0(n) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity:0(n) <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code ```java [] class Solution { public boolean hasSameDigits(String s) { int n=s.length(); if(n==2) return s.charAt(0) ==s.c...
1
0
['Java']
0
check-if-digits-are-equal-in-string-after-operations-i
Simple Go Solution !!
simple-go-solution-by-dipak__patil-73be
Code
dipak__patil
NORMAL
2025-02-23T04:01:37.176798+00:00
2025-02-23T04:01:37.176798+00:00
33
false
# Code ```golang [] func hasSameDigits(s string) bool { currList := []byte(s) insertPos := 0 for len(currList) > 2 { insertPos = 0 for i := 1; i < len(currList); i++ { currList[insertPos] = (byte(int(currList[i-1]-'0')+int(currList[i]-'0')) % 10) + '0' insertPos++ } currList = currList[:len(currList)-1...
1
0
['Go']
0
check-if-digits-are-equal-in-string-after-operations-i
Simple and clean approach
simple-and-clean-approach-by-manedeepu73-9gxm
IntuitionApproachComplexity Time complexity: Space complexity: Code
manedeepu73
NORMAL
2025-04-12T08:37:57.611896+00:00
2025-04-12T08:37:57.611896+00:00
1
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 `...
0
0
['JavaScript']
0
check-if-digits-are-equal-in-string-after-operations-i
My 88th Problem
my-88th-problem-by-chefcurry4-22sy
ApproachWe iteratively reduce the input string s by replacing it with a new string where each character is the sum modulo 10 of every pair of consecutive digits
Chefcurry4
NORMAL
2025-04-12T06:48:51.889314+00:00
2025-04-12T06:48:51.889314+00:00
1
false
# Approach We iteratively reduce the input string `s` by replacing it with a new string where each character is the sum modulo 10 of every pair of consecutive digits in `s`. This is repeated until only two digits remain. We then return True if the final two digits are the same, otherwise False. # Complexity - Time com...
0
0
['Math', 'String', 'Simulation', 'Combinatorics', 'Number Theory', 'Python']
0
check-if-digits-are-equal-in-string-after-operations-i
Simple and Easy User Friendly Code
simple-and-easy-user-friendly-code-by-ba-flrr
IntuitionThe problem asks to repeatedly sum adjacent digits modulo 10 until a two-digit number is obtained. Then, check if both digits are the same. A straightf
Balarakesh
NORMAL
2025-04-11T16:21:33.986540+00:00
2025-04-11T16:21:33.986540+00:00
1
false
# Intuition The problem asks to repeatedly sum adjacent digits modulo 10 until a two-digit number is obtained. Then, check if both digits are the same. A straightforward iterative approach seems suitable. # Approach 1. Iterate while the length of the input string `s` (or `num` in the code) is not 2. 2. In each itera...
0
0
['Python3']
0
check-if-digits-are-equal-in-string-after-operations-i
submission beat 91% of other submissions' runtime|| tc->o(n) || sc->o(1)||
submission-beat-91-of-other-submissions-6wmpc
IntuitionApproachComplexity Time complexity: Space complexity: Code
Rohan07_6473
NORMAL
2025-04-11T09:02:12.384893+00:00
2025-04-11T09:02:12.384893+00:00
0
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 `...
0
0
['C++']
0