Skip to content

Commit 311f225

Browse files
authored
Merge pull request SjxSubham#213 from AsparkArcane/3461
3461. Check if Digits Are Equal in String After Operations I
2 parents 4f5eb45 + 0860b90 commit 311f225

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
bool hasSameDigits(string s) {
4+
while(s.length() > 2){
5+
string temp = "";
6+
for(int i = 0; i < s.length()-1; i++){
7+
int a = s[i] - '0';
8+
int b = s[i + 1] - '0';
9+
temp.push_back(((a + b) % 10) + '0');
10+
}
11+
s = temp;
12+
}
13+
return s.length() && s[0] == s[1];
14+
}
15+
};

0 commit comments

Comments
 (0)