2840. Check if Strings Can be Made Equal With Operations II
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user