> For the complete documentation index, see [llms.txt](https://leetcode.realtemirov.uz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://leetcode.realtemirov.uz/problems/1790.-check-if-one-string-swap-can-make-strings-equal.md).

# 1790. Check if One String Swap Can Make Strings Equal

🟩 Easy

## Solution

My Solution

```go
func areAlmostEqual(s1 string, s2 string) bool {
    if len(s1) != len(s2) {
        return false
    }
    var (
        has, equal bool
        idx int
    )

    for i, s := range s1 {
        if s == rune(s2[i]) {
            continue
        }    

        if has {
            if equal {
                return false
            }
    
            if rune(s2[idx]) == s && s2[i] == s1[idx] {
                equal = true
            } else {
                return false
            }
        }

        has = true
        idx = i
    }
    if has {
        return equal
    }
    return true
}
```

![result](https://600345290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrSK2xH3txU3tYyDsT8mQ%2Fuploads%2Fgit-blob-f7af35b2081f73960bf3712b7d7b5c6ca12dddd1%2F1790.png?alt=media)

Leetcode: [link](https://leetcode.com/problems/check-if-one-string-swap-can-make-strings-equal/description/)
