✔️ Easiest Solution & Beginner Friendly ✔️ | 🌟 O(N * Log(N)) 🌟 |🔥 Modular Arithmetic + Greedy 🔥 
IntuitionThe function checks whether the alternatingsumofadjacent digitsin a string remains the same for all such pairs. Instead of computing all possible sumsd
# Intuition
The function checks whether the alternating `sum` of **adjacent digits** in a string remains the same for all such pairs. Instead of computing all possible sums **directly**, it leverages **modular arithmetic** and properties of **binomial coefficients** to efficiently determine the result. By breaking down binomial coefficients modulo **10** using **mod 2** and **mod 5** separately and then reconstructing them via the **Chinese Remainder Theorem**, the approach avoids redundant calculations, making it highly efficient.

# Approach
`Step 1` **Initialize Variables**
- Store the given string `s` in `helperS` 
- Define `size = s.length()`, and `set X = size - 2`
- Initialize `x = 0` and `y = 0`, which will hold the computed alternating `sums`.

`Step 2` **Compute Alternating Sum Using Binomial Coefficients**
- Iterate over the range `0 - X`
- Compute the **binomial coefficient** `modulo 10` using `binomialMod10(X, j)`.
- Add this weighted value to both `x` and `y` using modular arithmetic.

`Step 3` **Compare Alternating Sums**
- If `x == y`, return `true`; otherwise, return `false`.

`Step 4` **Compute Binomial Coefficient Modulo 10**
- Compute **binomial coefficients** separately for `mod 2` and `mod 5` using `binomialMod2` and `binomialMod5`.
- Use the **Chinese Remainder Theorem** to reconstruct the binomial coefficient `modulo 10`.

`Step 5` **Compute Binomial Coefficients Modulo 2 and Modulo 5**
- **For mod 2**: Use **bitwise operations** `n & k` to determine the `result` efficiently.
- **For mod 5**: Use a **lookup table** for **Pascal’s Triangle** properties `modulo 5` to get the value efficiently.


# Complexity
- Time complexity : $$O(n * log(n))$$
- Space complexity : $$O(1)$$
 
# Code
```Java []
class Solution 
{
    public boolean hasSameDigits(String s) 
    {
        // Step 1: Initialize Variables
        int size = s.length();
        int X = size - 2;
        int x = 0, y = 0;

        // Step 2: Compute Alternating Sum Using Binomial Coefficients
        for (int j = 0; j <= X; j++) 
        {
            int coeff = binomialMod10(X, j);
            x = (x + coeff * (s.charAt(j) - '0')) % 10;
            y = (y + coeff * (s.charAt(j + 1) - '0')) % 10;
        }

        // Step 3: Compare Alternating Sums
        return x == y;
    }

    // Step 4: Compute Binomial Coefficient Modulo 10
    private int binomialMod10(int n, int k) 
    {
        int i = binomialMod2(n, k);
        int j = binomialMod5(n, k);

        for (int x = 0; x < 10; x++) 
        {
            if (x % 2 == i && x % 5 == j) 
            {
                return x;
            }
        }
        return 0;
    }

    // Step 5: Compute Binomial Coefficient Modulo 2
    private int binomialMod2(int n, int k) 
    {
        return ((n & k) == k) ? 1 : 0;
    }

    // Step 6: Compute Binomial Coefficient Modulo 5 Using Lookup Table
    private int binomialMod5(int n, int k) 
    {
        int[][] tuples = {{1}, {1, 1}, {1, 2, 1}, {1, 3, 3, 1}, {1, 4, 1, 4, 1}};
        int result = 1;

        while (n > 0 || k > 0) 
        {
            int nthd = n % 5;
            int kthd = k % 5;

            if (kthd > nthd) return 0;

            result = (result * tuples[nthd][kthd]) % 5;
            n /= 5;
            k /= 5;
        }
        return result;
    }
}
```
``` C++ []
class Solution 
{
public:
    bool hasSameDigits(string s) 
    {
        // Step 1: Initialize Variables
        int size = s.length();
        int X = size - 2;
        int x = 0, y = 0;

        // Step 2: Compute Alternating Sum Using Binomial Coefficients
        for (int j = 0; j <= X; j++) 
        {
            int coeff = binomialMod10(X, j);
            x = (x + coeff * (s[j] - '0')) % 10;
            y = (y + coeff * (s[j + 1] - '0')) % 10;
        }

        // Step 3: Compare Alternating Sums
        return x == y;
    }

private:
    // Step 4: Compute Binomial Coefficient Modulo 10
    int binomialMod10(int n, int k) 
    {
        int i = binomialMod2(n, k);
        int j = binomialMod5(n, k);

        for (int x = 0; x < 10; x++) 
        {
            if (x % 2 == i && x % 5 == j) 
            {
                return x;
            }
        }
        return 0;
    }

    // Step 5: Compute Binomial Coefficient Modulo 2
    int binomialMod2(int n, int k) 
    {
        return ((n & k) == k) ? 1 : 0;
    }

    // Step 6: Compute Binomial Coefficient Modulo 5 Using Lookup Table
    int binomialMod5(int n, int k) 
    {
        int tuples[5][5] = {{1}, {1, 1}, {1, 2, 1}, {1, 3, 3, 1}, {1, 4, 1, 4, 1}};
        int result = 1;

        while (n > 0 || k > 0) 
        {
            int nthd = n % 5;
            int kthd = k % 5;

            if (kthd > nthd) return 0;

            result = (result * tuples[nthd][kthd]) % 5;
            n /= 5;
            k /= 5;
        }
        return result;
    }
};
````
['Array', 'Math', 'Two Pointers', 'Greedy', 'Bit Manipulation', 'Bitmask', 'C++', 'Java']