🔥 100% Beast Mode Activated! 🚀 Ultra-Efficient Java Solution
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
# 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 record only the last digit.
3️⃣ Repeat until only two digits remain → Check if they are the same.

This feels like a shrinking sequence, where we repeatedly compress information step by step until we reach a final, condensed result.

# Approach
<!-- Describe your approach to solving the problem. -->
1. Convert the string into an integer array.
2. Iterate while n > 2 and repeatedly transform the array:
3. Compute (digits[i] + digits[i+1]) % 10 for each pair.
4. Store the new values in place.
5. Reduce n after each pass.
6. Return true if the last two digits are equal, otherwise false.

# Complexity
- Time complexity: O(n²)
- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public boolean hasSameDigits(String s) {
        int n = s.length();
        int[] digits = new int[n];
        // can also be done using string builder
        // Convert the string to an integer array
        for (int i = 0; i < n; i++) {
            digits[i] = s.charAt(i) - '0';
        }
        // Process the array until only two elements remain
        while (n > 2) {
            for (int i = 0; i < n - 1; i++) {
                digits[i] = (digits[i] + digits[i + 1]) % 10;
            }
            // Reduce effective array size
            n--;
        }
        return digits[0] == digits[1];
    }
}
```
['Java']