Refer for code: -
Use an unordered_map in place of map and then check.
Thanks @pratyush63 All the testcases are successfully passed