🔥Simple Code🔥- 🌟O(N) TC and O(1) SC🌟 - Binomial Coefficients✅ and Pascal’s triangle sequence✅ 
IntuitionApproachComplexity

Time complexity: O(N)


Space complexity: O(1)

Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

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

# Complexity
- Time complexity: O(N)

- Space complexity: O(1)

# Code
```python3 []
class Solution:
    def hasSameDigits(self, s: str) -> bool:
        n = len(s)
        if n <= 2:
            return s[0] == s[1]
        
        pascal = n - 1  
        diff = (int(s[0]) - int(s[n - 1])) % 10
        
        rem, count2, count5 = 1, 0, 0
        
        inverse = {1: 1, 3: 7, 7: 3, 9: 9}
        
        def factorize(x: int):
            count2 = count5 = 0
            while x % 2 == 0:
                count2 += 1
                x //= 2
            while x % 5 == 0:
                count5 += 1
                x //= 5
            return x % 10, count2, count5
        
        for i in range(1, pascal):
            num = pascal - i      
            den = i          
            
            r_num, cnt2_num, cnt5_num = factorize(num)
            r_den, cnt2_den, cnt5_den = factorize(den)
            
            rem = (rem * r_num * inverse[r_den]) % 10
            count2 = count2 + cnt2_num - cnt2_den
            count5 = count5 + cnt5_num - cnt5_den
            
            if count2 > 0 and count5 > 0:
                c = 0
            elif count2 > 0:
                power = [6, 2, 4, 8] 
                two_mod = power[count2 % 4] if count2 % 4 != 0 else 6
                c = (rem * two_mod) % 10
            elif count5 > 0:
                c = (rem * 5) % 10
            else:
                c = rem
            
            diff = (diff + (int(s[i]) - int(s[n - 1 - i])) * c) % 10
        
        return diff % 10 == 0

```
```java []
class Solution {
    public boolean hasSameDigits(String s) {
        int n = s.length();
        if (n <= 2) {
            return s.charAt(0) == s.charAt(1);
        }

        int pascal = n - 1;
        int diff = (Character.getNumericValue(s.charAt(0)) - Character.getNumericValue(s.charAt(n - 1))) % 10;

        int rem = 1, count2 = 0, count5 = 0;

        int[] inverse = {0, 1, 0, 7, 0, 0, 0, 3, 0, 9};

        for (int i = 1; i < pascal; i += 1) {
            int num = pascal - i;
            int den = i;

            int[] numResult = factorize(num);
            int[] denResult = factorize(den);

            rem = (rem * numResult[0] * inverse[denResult[0]]) % 10;
            count2 = count2 + numResult[1] - denResult[1];
            count5 = count5 + numResult[2] - denResult[2];

            int c;
            if (count2 > 0 && count5 > 0) {
                c = 0;
            } else if (count2 > 0) {
                int[] power = {6, 2, 4, 8};
                int twoMod = power[count2 % 4];
                if(count2 % 4 == 0) twoMod = 6;
                c = (rem * twoMod) % 10;
            } else if (count5 > 0) {
                c = (rem * 5) % 10;
            } else {
                c = rem;
            }

            diff = (diff + (Character.getNumericValue(s.charAt(i)) - Character.getNumericValue(s.charAt(n - 1 - i))) * c) % 10;
        }

        return diff % 10 == 0;
    }

    private int[] factorize(int x) {
        int count2 = 0, count5 = 0;
        while (x % 2 == 0) {
            count2 += 1;
            x /= 2;
        }
        while (x % 5 == 0) {
            count5 += 1;
            x /= 5;
        }
        return new int[]{x % 10, count2, count5};
    }
}
```
```cpp []
class Solution {
private:
    vector<int> factorize(int x) {
        int count2 = 0, count5 = 0;
        while (x % 2 == 0) {
            count2 += 1;
            x /= 2;
        }
        while (x % 5 == 0) {
            count5 += 1;
            x /= 5;
        }
        return {x % 10, count2, count5};
    }

public:
    bool hasSameDigits(string s) {
        int n = s.length();
        if (n <= 2) {
            return s[0] == s[1];
        }

        int pascal = n - 1;
        int diff = (s[0] - s[n - 1]) % 10;

        int rem = 1, count2 = 0, count5 = 0;

        int inverse[] = {0, 1, 0, 7, 0, 0, 0, 3, 0, 9};

        for (int i = 1; i < pascal; i += 1) {
            int num = pascal - i;
            int den = i;

            vector<int> numResult = factorize(num);
            vector<int> denResult = factorize(den);

            rem = (rem * numResult[0] * inverse[denResult[0]]) % 10;
            count2 = count2 + numResult[1] - denResult[1];
            count5 = count5 + numResult[2] - denResult[2];

            int c;
            if (count2 > 0 && count5 > 0) {
                c = 0;
            } else if (count2 > 0) {
                int power[] = {6, 2, 4, 8};
                int twoMod = power[count2 % 4];
                if(count2 % 4 == 0) twoMod = 6;
                c = (rem * twoMod) % 10;
            } else if (count5 > 0) {
                c = (rem * 5) % 10;
            } else {
                c = rem;
            }

            diff = (diff + (s[i] - s[n - 1 - i]) * c) % 10;
        }

        return diff % 10 == 0;
    }
};
```
['C++', 'Java', 'Python3']