🔢 Check if a Number String Reduces to Two Same Digits
✅ IntuitionThe problem requires checking whether a string of digits, through a series of transformations, reduces to two identical digits.
In each transformatio
## ✅ **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.
- This process continues until the string contains only **two digits**.  
- Finally, compare the two digits to see if they are the same.

---

## 🔥 **Approach**
1. **Iterate Until Length Reduces to 2:**  
   - Use a loop to repeatedly transform the string until it has only two digits.
   
2. **Form a New String in Each Iteration:**  
   - Use a `StringBuilder` to build the new string.
   - Iterate through adjacent pairs of digits:
     - Convert each character to an integer.
     - Add the two adjacent digits.
     - Append the last digit of the sum (`(firstDigit + secondDigit) % 10`) to the new string.  
   
3. **Repeat the Process:**  
   - Update the string to the new transformed string.
   - Continue the transformation process until the string length becomes **2**.
   
4. **Final Check:**  
   - Compare the two digits:
     - If they are the same, return `true`.
     - Otherwise, return `false`.

---

## ⏱️ **Complexity Analysis**
- **Time Complexity:**  
  - Each iteration reduces the string length by **1**, making the process $$O(n)$$, where `n` is the initial length of the string.  
  - Since the transformation continues until the string length becomes **2**, it takes approximately $$O(n)$$ steps.  

- **Space Complexity:**  
  - $$O(n)$$ for the `StringBuilder` used to store the transformed string at each step.

---

## 🛠️ **Code**
```java
class Solution {
    public boolean hasSameDigits(String s) {
        while (s.length() > 2){
            StringBuilder newString = new StringBuilder();
            
            for (int i = 0; i < s.length() - 1; i++){
                int firstDigit = s.charAt(i) - '0';          // Convert char to int
                int secondDigit = s.charAt(i + 1) - '0';     // Convert char to int
                int newDigit = (firstDigit + secondDigit) % 10;  
                newString.append(newDigit);      
            }
            
            s = newString.toString();
        }
        return s.charAt(0) == s.charAt(1);
    }
}
```
['Java']