Given two strings consisting of lowercase english alphabets, the task is to check whether these strings are meta strings or not. Meta strings are the strings which can be made equal by exactly one swap in any of the strings. Equal string are not considered here as Meta strings.
Input: S1 = "geeks", S2 = "keegs" Output: 1 Explanation: We can swap the 0th and 3rd character of S2 to make it equal to S1.
Input: S1 = "geeks", S2 = "geeks" Output: 0 Explanation: Equal strings are not considered Meta strings.
You don't need to read input or print anything. Your task is to complete the function metaStrings() which takes the strings S1 and S2 as input and returns true if both the strings are meta strings, else it returns false.
Expected Time Complexity: O(|S|).
Expected Auxiliary Space: O(1).
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?Yes