diff --git a/2840. Check if Strings Can be Made Equal With Operations II/2840. Check if Strings Can be Made Equal With Operations II.csproj b/2840. Check if Strings Can be Made Equal With Operations II/2840. Check if Strings Can be Made Equal With Operations II.csproj new file mode 100644 index 0000000..1b37fa9 --- /dev/null +++ b/2840. Check if Strings Can be Made Equal With Operations II/2840. Check if Strings Can be Made Equal With Operations II.csproj @@ -0,0 +1,11 @@ + + + + Exe + net10.0 + _2840._Check_if_Strings_Can_be_Made_Equal_With_Operations_II + enable + enable + + + diff --git a/2840. Check if Strings Can be Made Equal With Operations II/Program.cs b/2840. Check if Strings Can be Made Equal With Operations II/Program.cs new file mode 100644 index 0000000..04c226e --- /dev/null +++ b/2840. Check if Strings Can be Made Equal With Operations II/Program.cs @@ -0,0 +1,2 @@ +var sol = new Solution(); +System.Console.WriteLine(sol.CheckStrings("abe", "bea")); \ No newline at end of file diff --git a/2840. Check if Strings Can be Made Equal With Operations II/Solution.cs b/2840. Check if Strings Can be Made Equal With Operations II/Solution.cs new file mode 100644 index 0000000..d0cf6e0 --- /dev/null +++ b/2840. Check if Strings Can be Made Equal With Operations II/Solution.cs @@ -0,0 +1,25 @@ +public class Solution +{ + public bool CheckStrings(string s1, string s2) + { + var d1 = new char['z' - 'a' + 1]; + var d2 = new char['z' - 'a' + 1]; + for (var i = 0; i < s1.Length; i += 2) + { + d1[s1[i]-'a']++; + d1[s2[i]-'a']--; + if (i + 1 < s1.Length) + { + d2[s1[i + 1]-'a']++; + d2[s2[i + 1]-'a']--; + } + } + foreach (var c in d1) + if (c != 0) + return false; + foreach (var c in d2) + if (c != 0) + return false; + return true; + } +} \ No newline at end of file diff --git a/Leetcode.sln b/Leetcode.sln index 926faa5..23425b8 100644 --- a/Leetcode.sln +++ b/Leetcode.sln @@ -201,6 +201,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3548. Equal Sum Grid Partit EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2946. Matrix Similarity After Cyclic Shifts", "2946. Matrix Similarity After Cyclic Shifts\2946. Matrix Similarity After Cyclic Shifts.csproj", "{8BC4770E-4B28-4AE4-8066-3609E4298363}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2840. Check if Strings Can be Made Equal With Operations II", "2840. Check if Strings Can be Made Equal With Operations II\2840. Check if Strings Can be Made Equal With Operations II.csproj", "{5020405E-5F4F-4AC6-932D-00F01643A2F0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1399,6 +1401,18 @@ Global {8BC4770E-4B28-4AE4-8066-3609E4298363}.Release|x64.Build.0 = Release|Any CPU {8BC4770E-4B28-4AE4-8066-3609E4298363}.Release|x86.ActiveCfg = Release|Any CPU {8BC4770E-4B28-4AE4-8066-3609E4298363}.Release|x86.Build.0 = Release|Any CPU + {5020405E-5F4F-4AC6-932D-00F01643A2F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5020405E-5F4F-4AC6-932D-00F01643A2F0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5020405E-5F4F-4AC6-932D-00F01643A2F0}.Debug|x64.ActiveCfg = Debug|Any CPU + {5020405E-5F4F-4AC6-932D-00F01643A2F0}.Debug|x64.Build.0 = Debug|Any CPU + {5020405E-5F4F-4AC6-932D-00F01643A2F0}.Debug|x86.ActiveCfg = Debug|Any CPU + {5020405E-5F4F-4AC6-932D-00F01643A2F0}.Debug|x86.Build.0 = Debug|Any CPU + {5020405E-5F4F-4AC6-932D-00F01643A2F0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5020405E-5F4F-4AC6-932D-00F01643A2F0}.Release|Any CPU.Build.0 = Release|Any CPU + {5020405E-5F4F-4AC6-932D-00F01643A2F0}.Release|x64.ActiveCfg = Release|Any CPU + {5020405E-5F4F-4AC6-932D-00F01643A2F0}.Release|x64.Build.0 = Release|Any CPU + {5020405E-5F4F-4AC6-932D-00F01643A2F0}.Release|x86.ActiveCfg = Release|Any CPU + {5020405E-5F4F-4AC6-932D-00F01643A2F0}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE