a few solutions
Peform a linear scan of each string s in the input array A and count cnt reductions performed when target t is previously seen.\n\n---\n\nKotlin\n\nclass Soluti
Peform a linear scan of each string `s` in the input array `A` and count `cnt` reductions performed when target `t` is previously `seen`.\n\n---\n\n*Kotlin*\n```\nclass Solution {\n    fun maximumNumberOfStringPairs(A: Array<String>): Int {\n        var cnt = 0\n        var seen = mutableSetOf<String>()\n        for (s in A) {\n            var t = s.toCharArray().reversed().joinToString("")\n            if (seen.contains(t)) {\n                ++cnt; seen.remove(t)\n            } else {\n                seen.add(s)\n            }\n        }\n        return cnt\n    }\n}\n```\n\n*Javascript*\n```\nlet maximumNumberOfStringPairs = (A, seen = new Set(), cnt = 0) => {\n    for (let s of A) {\n        let t = s.split(\'\').reverse().join(\'\');\n        if (seen.has(t))\n            ++cnt, seen.delete(t);\n        else\n            seen.add(s);\n    }\n    return cnt;\n};\n```\n\n*Python3*\n```\nclass Solution:\n    def maximumNumberOfStringPairs(self, A: List[str], cnt = 0) -> int:\n        seen = set()\n        for s in A:\n            t = \'\'.join(reversed(list(s)))\n            if t in seen:\n                cnt += 1; seen.remove(t)\n            else:\n                seen.add(s)\n        return cnt\n```\n\n*Rust*\n```\ntype VS = Vec<String>;\nuse std::collections::HashSet;\nimpl Solution {\n    pub fn maximum_number_of_string_pairs(A: VS) -> i32 {\n        let mut cnt = 0;\n        let mut seen = HashSet::new();\n        for s in A {\n            let t = s.clone().chars().rev().collect::<String>();\n            if seen.contains(&t) {\n                cnt += 1; seen.remove(&t);\n            } else {\n                seen.insert(s);\n            }\n        }\n        cnt\n    }\n}\n```\n\n*C++*\n```\nclass Solution {\npublic:\n    using VS = vector<string>;\n    using Set = unordered_set<string>;\n    int maximumNumberOfStringPairs(VS& A, Set seen = {}, int cnt = 0) {\n        for (auto& s: A) {\n            auto t = string{s.rbegin(), s.rend()};\n            if (seen.find(t) != seen.end())\n                ++cnt, seen.erase(t);\n            else\n                seen.insert(s);\n        }\n        return cnt;\n    }\n};\n```
[]