3461. Check If Digits Are Equal in String After Operations I
You are given a string
sconsisting of digits. Perform the following operation repeatedly until the string has exactly two digits:
- For each pair of consecutive digits in
s, starting from the first digit, calculate a new digit as the sum of the two digits modulo 10.- Replace
swith the sequence of newly calculated digits, maintaining the order in which they are computed.Return
trueif the final two digits insare the same; otherwise, returnfalse.
1 | class Solution { |