✅0ms~ Solution⚡ || BEATS 💯%⚡[C++/Java/Py3/JS]👀 || SIMPLE CODE-EASYASF SOLUTION🚀 
Intuition:The problem requires checking if two strings can be made equal by swapping exactly one pair of characters. If the strings are already equal, return tr

# Intuition:
The problem requires checking if two strings can be made equal by swapping exactly one pair of characters. If the strings are already equal, return `true`. Otherwise, identify differing positions and ensure that swapping them results in equality.

# Approach:
1. **Check if both strings are already equal**  
   - If `s1 == s2`, return `true` immediately.
   
2. **Find differing indices**  
   - Traverse both strings and collect indices where characters differ.

3. **Check conditions for a valid swap**  
   - If there are exactly two differing indices, verify if swapping them makes the strings equal.
   - If more than two differences exist, return `false`.

# Complexity:
- **Time Complexity:** O(n) (single pass to find differences)
- **Space Complexity:** O(1) (only storing at most two indices)

# Code:
```cpp []
class Solution {
public:
    bool areAlmostEqual(string s1, string s2) {
        if (s1 == s2) return true;
        vector<int> swapIndex;
        for (int i = 0; i < s1.length(); i++) {
            if (s1[i] != s2[i]) {
                swapIndex.emplace_back(i);
            }
        }
        if (swapIndex.size() == 2) {
            int i = swapIndex[0], j = swapIndex[1];
            return (s1[i] == s2[j] && s1[j] == s2[i]);
        }return false;
    }
};
```
```python []
class Solution:
    def areAlmostEqual(self, s1: str, s2: str) -> bool:
        if s1 == s2:
            return True
        swap_index = [i for i in range(len(s1)) if s1[i] != s2[i]]
        if len(swap_index) == 2:
            i, j = swap_index
            return s1[i] == s2[j] and s1[j] == s2[i]
        return False
```
```java []

class Solution {
    public boolean areAlmostEqual(String s1, String s2) {
        if (s1.equals(s2)) return true;
        List<Integer> swapIndex = new ArrayList<>();
        for (int i = 0; i < s1.length(); i++) {
            if (s1.charAt(i) != s2.charAt(i)) {
                swapIndex.add(i);
            }
        }
        if (swapIndex.size() == 2) {
            int i = swapIndex.get(0), j = swapIndex.get(1);
            return (s1.charAt(i) == s2.charAt(j) && s1.charAt(j) == s2.charAt(i));
        }return false;
    }
}

/* 100%
class Solution {
    public boolean areAlmostEqual(String s1, String s2) {
        if (s1.equals(s2)) {
            return true;
        }
        char[] s1FrequencyMap = new char[26];
        char[] s2FrequencyMap = new char[26];
        int numDiffs = 0;

        for (int i = 0; i < s1.length(); i++) {
            char s1Char = s1.charAt(i);
            char s2Char = s2.charAt(i);

            if (s1Char != s2Char) {
                numDiffs++;
                if (numDiffs > 2)
                    return false;
            }
            s1FrequencyMap[s1Char - 'a']++;
            s2FrequencyMap[s2Char - 'a']++;
        }return Arrays.equals(s1FrequencyMap, s2FrequencyMap);
    }
}
*/
```

```javascript []
/**
 * @param {string} s1
 * @param {string} s2
 * @return {boolean}
 */
var areAlmostEqual = function(s1, s2) {
    if (s1 === s2) return true;
    let swapIndex = [];
    for (let i = 0; i < s1.length; i++) {
        if (s1[i] !== s2[i]) {
            swapIndex.push(i);
        }
    }
    if (swapIndex.length === 2) {
        let [i, j] = swapIndex;
        return s1[i] === s2[j] && s1[j] === s2[i];
    }return false;
};

```

```
✨ AN UPVOTE WILL BE APPRECIATED ^_~ ✨
```
['String', 'Python', 'C++', 'Java', 'Python3', 'JavaScript']