C++ | Easy to Understand | 3 ms | Beginner Friendly
Intuition\n Describe your first thoughts on how to solve this problem. \nfind all possible start and end points then find the minimum path distance required to 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nfind all possible start and end points then find the minimum path distance required to connect them and store the answers based on the distance\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nwe use an array to store the count for every distance ie 1<=k<=n\n\nwe use two loops to find all possible start and end points then we find the min path dist between them either directly without using x and y or by using x and y then based on the distance found we add 2 to the corresponding position on the array\n\n\n# Complexity\n- Time complexity: O(n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> countOfPairs(int n, int x, int y) {\n        vector<int> result(n, 0);\n        for (int i = 1; i <= n; i++) {\n            for (int j = i + 1; j <= n; j++) {\n                int distance = min({abs(i - j), abs(i - x) + 1 + abs(j - y), abs(i - y) + 1 + abs(j - x)});\n                result[distance - 1] += 2;\n            }\n        }\n        return result;\n    }\n};\n```
['C++']