LeetCodeMetaData / check-if-strings-can-be-made-equal-with-operations-ii.json
DataRepo's picture
Upload part 1 of 2
4097b71 verified
{
"id": 2978,
"name": "check-if-strings-can-be-made-equal-with-operations-ii",
"difficulty": "Medium",
"link": "https://leetcode.com/problems/check-if-strings-can-be-made-equal-with-operations-ii/",
"date": "2023-08-19",
"task_description": "You are given two strings `s1` and `s2`, both of length `n`, consisting of **lowercase** English letters. You can apply the following operation on **any** of the two strings **any** number of times: Choose any two indices `i` and `j` such that `i < j` and the difference `j - i` is **even**, then **swap** the two characters at those indices in the string. Return `true`_ if you can make the strings _`s1`_ and _`s2`_ equal, and _`false`_ otherwise_. **Example 1:** ``` **Input:** s1 = \"abcdba\", s2 = \"cabdab\" **Output:** true **Explanation:** We can apply the following operations on s1: - Choose the indices i = 0, j = 2. The resulting string is s1 = \"cbadba\". - Choose the indices i = 2, j = 4. The resulting string is s1 = \"cbbdaa\". - Choose the indices i = 1, j = 5. The resulting string is s1 = \"cabdab\" = s2. ``` **Example 2:** ``` **Input:** s1 = \"abe\", s2 = \"bea\" **Output:** false **Explanation:** It is not possible to make the two strings equal. ``` **Constraints:** `n == s1.length == s2.length` `1 <= n <= 105` `s1` and `s2` consist only of lowercase English letters.",
"test_case": [
{
"label": "Example 1",
"input": "s1 = \"abcdba\", s2 = \"cabdab\"",
"output": "true "
},
{
"label": "Example 2",
"input": "s1 = \"abe\", s2 = \"bea\"",
"output": "false "
}
],
"constraints": [
"Choose any two indices i and j such that i < j and the difference j - i is even, then swap the two characters at those indices in the string.",
"n == s1.length == s2.length",
"1 <= n <= 105",
"s1 and s2 consist only of lowercase English letters."
],
"python_template": "class Solution(object):\n def checkStrings(self, s1, s2):\n \"\"\"\n :type s1: str\n :type s2: str\n :rtype: bool\n \"\"\"\n ",
"java_template": "class Solution {\n public boolean checkStrings(String s1, String s2) {\n \n }\n}",
"metadata": {
"func_name": "checkStrings"
}
}