C++ Math - set inclusion-exclusion principle
\n# Code\n\nclass Solution {\n    inline int getPower(const int base, const int exponent,const int mod){\n        int ans=1;\n        for (int i=0;i<exponent;i+
\n# Code\n```\nclass Solution {\n    inline int getPower(const int base, const int exponent,const int mod){\n        int ans=1;\n        for (int i=0;i<exponent;i++) ans = (1LL*ans*base)%mod;\n        return ans;\n    }\npublic:\n    int stringCount(int n) {\n        int mod = 1000000007;\n        int totalCombinations = getPower(26,n,mod); \n        int zeroLCombinations = getPower(25,n,mod); //set 1\n        int zeroTCombinations = zeroLCombinations; // set 2\n        int zeroECombinations = zeroLCombinations; // set 3\n        int oneECombinations = (1LL*n*getPower(25,n-1,mod))%mod; // set 4\n        int intersect1And2 = getPower(24,n,mod);\n        int intersect1And3 = intersect1And2;\n        int intersect1And4 = (1LL * n*getPower(24,n-1,mod))%mod;\n        int intersect2And3 = intersect1And2;\n        int intersect2And4 = intersect1And4;\n        int intersect3And4 = 0;\n        int intersect123 = getPower(23,n,mod);\n        int intersect124 = (1LL*n*getPower(23,n-1,mod))%mod;\n        int intersect134 =0;\n        int intersect234 =0;\n        int intersectAll = 0;\n        //7LL is because we are performing 7 mod substraction\n        //formula for mod substraction is (n1-n2+mod)%mod\n        return (7LL*mod + totalCombinations - zeroLCombinations - zeroTCombinations - zeroECombinations - oneECombinations +intersect1And2 +  intersect1And3 + intersect1And4 + intersect2And3 + intersect2And4 + intersect3And4 - intersect123 - intersect124 - intersect134 - intersect234 + intersectAll)%mod;\n    }\n};\n```
['C++']