Easy Cpp Solution Beats 100.00% 🙌 || Check-if-one-string-swap-can-make-Strings-Equal
IntuitionThe problem statement is we need to do atmost one swap to get our required string text s1, so here we get to understand that string s2 is the string to
# Intuition
The problem statement is we need to do atmost one swap to get our required string text s1, so here we get to understand that string s2 is the string to be swapped.

# Approach
so in the Beginning of the problem, we check whether the two strings are same or not, if same, we return True. else we check through each index, where we get to know only two index is supposed to be swapped to get rid off the misplaced characters. so we perform iterative approach till the end of the strings with same length. if same, we process through that else, we mark that index, so that we'll obtain the indexes that is supposed to be swapped.

# Complexity
- Time complexity:
O(N)

- Space complexity:
O(1)

Please do UPVOTE, if you find this solution very useful. thank you.
# Code
```cpp []
class Solution {
public:
    void swapChars(string &text, int m1, int m2) {
        char c = text[m1];
        text[m1] = text[m2];
        text[m2] = c;
    }

    bool areAlmostEqual(string s1, string s2) {
        if(s1==s2)
        {
            return true;
        }
        if (s1.size() != s2.size()) {
              return false;
        }

        int mark1 = -1, mark2 = -1;
        for (int i = 0; i < s1.size(); i++) {
            if (s1[i] != s2[i]) {
                if (mark1 == -1) {
                    mark1 = i;
            }else if (mark2 == -1) {
                mark2 = i;
            }else {
                return false;
            }
            }
        }

        if (mark1 == -1 || mark2==-1) {
            return false;
        }

        swapChars(s2, mark1, mark2);
        return s1 == s2 ? true:false;
    }
};
```
['C++']