LeetCode 1790. Check if One String Swap Can Make Strings Equal in F#
URL
Check if One String Swap Can Make Strings Equal - LeetCode
Code
let areAlmostEqual (s1: string) (s2: string) : bool =
let v = Seq.zip s1 s2 |> Seq.filter (fun (c1, c2) -> c1 <> c2) |> Seq.toList
match v with
| [] -> true
| _ :: [] -> false
| (a1, a2) :: (b1, b2) :: [] when a1 = b2 && a2 = b1 -> true
| _ -> false