Using Character Array and HashMap
IntuitionUsing Character Array and HashMapApproachIterative Transformation:The while loop runs until the length of s is reduced to 2.
In each iteration, calcula
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Using Character Array and HashMap

# Approach
<!-- Describe your approach to solving the problem. -->
Iterative Transformation:

The while loop runs until the length of s is reduced to 2.
In each iteration, calculateNewS(s, n) is called, which generates a new string s by applying the transformation.
Transformation Logic (calculateNewS method):

Iterate through adjacent character pairs in s.
1. To Compute the sum of the two digits, Character.getNumericValue(c[i]) gives the numeric value of that character
2. Store only the last digit of the sum (sum % 10) in a HashMap<Integer, String>.
3. Join the transformed values to form a new string.
4. Return the updated string.


# 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)$$ -->

# Code
```java []
class Solution {
    public boolean hasSameDigits(String s) {
        int n=s.length();
        
        while(n!=2){
           s=calculateNewS(s,n);
           n=s.length();
        }
        if(n==2){
            if (s.charAt(0)==s.charAt(1)){
                return true;
            }
        }
        return false;
    }

        private String calculateNewS(String s,int n){
            Map<Integer,String> nmap=new HashMap<>();
            char[] c=s.toCharArray();
            for(int i=0;i<n-1;i++){
                Integer sum=Character.getNumericValue(c[i])+Character.getNumericValue(c[i+1]);
                nmap.put(i, String.valueOf((sum)%10));
            }
            return nmap.values().stream().collect(Collectors.joining());

        }  
}
```
['Java']