LeetCode 1408. String Matching in an Array in F#

URL

https://leetcode.com/problems/string-matching-in-an-array/description/?envType=daily-question&envId=2025-01-07

Code

https://github.com/syohex/dotnet-study/blob/master/fsharp/leetcode/challenge/202501/string_matching_in_an_array/main.fsx

let stringMatching (words: string list) : string list =
    let words = List.indexed words

    words
    |> List.fold
        (fun acc (i, word) ->
            match List.tryFind (fun (j, (w: string)) -> i <> j && w.Contains(word)) words with
            | Some(_) -> word :: acc
            | None -> acc)
        []