c++() brute force
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n  int countPairs(vector<int>& nums) {\n    int n = nums.size();\n    vector<vector<int>> t(n, vector<int>(8,0));\n\n    for(int i = 0; i != n; i++){\n      int x = nums[i], id = -1;\n      while(x){\n        t[i][++id] = x%10;\n        x /= 10;\n      }\n    }\n\n    int ans = 0;\n    int na[8], nb[8];\n\n    for(int i = 0; i != n-1; i++){\n      for(int j = i+1; j != n; j++){\n\n        int size = 0;  \n        for(int k = 0; k != t[i].size(); k++)\n          if(t[i][k] != t[j][k]) {\n            if(size == 4) goto mark;\n            na[size] = t[i][k], nb[size] = t[j][k];\n            size++;  \n          }\n\n        if( size == 0 ||\n          ( size == 2 && na[0] == nb[1] && nb[0] == na[1] ) ||\n          ( size == 3 && ( (na[0] == nb[1] && na[1] == nb[2] && na[2] == nb[0]) ||\n                           (na[0] == nb[2] && na[1] == nb[0] && na[2] == nb[1]))) || \n          ( size == 4 && ( (na[0] == nb[1] && nb[0] == na[1] && na[2] == nb[3] && nb[2] == na[3]) ||\n                           (na[0] == nb[2] && nb[0] == na[2] && na[1] == nb[3] && nb[1] == na[3]) ||\n                           (na[0] == nb[3] && nb[0] == na[3] && na[1] == nb[2] && nb[1] == na[2]) ))) ans++;\n        mark:\n      }    \n    }    \n    return ans;  \n  }\n};\n```
['C++']