My solution
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```\nclass Solution {\n    public long[] countOfPairs(int n, int x, int y) {\n        long[] res = new long[n];\n        if (x == y || Math.abs(y - x) == 1) {\n            for (int i = 0; i < n - 1; i++) {\n                res[i] = (n - i - 1) * 2;\n            }\n        } else {\n            if (x > y) {\n                int tmpX = x;\n                x = y;\n                y = tmpX;\n            }\n            int tmp = n - y + x + 1;\n            for (int i = 0; i < tmp - 1; i++) {\n                res[i] = (tmp - i - 1) * 2;\n            }\n            res[0] -= 2;\n            tmp = y - x + 1;\n            int a = tmp / 2;\n            int b = tmp % 2;\n            for (int i = 0; i < a; i++) {\n                res[i] += 2 * tmp;\n            }\n            if (b == 0)\n                res[a - 1] -= tmp;\n\n            tmp -= 1;\n            for (int i = 1; i <= a + x - 1 - 1; i++) {\n                res[i] += ((Math.min(tmp, i * 2) - 1) - (Math.max((i - (x - 1)) * 2 - 1, 0))) * 2;\n            }\n\n            x = n - y + 1;\n            for (int i = 1; i <= a + x - 1 - 1; i++) {\n                res[i] += ((Math.min(tmp, i * 2) - 1) - (Math.max((i - (x - 1)) * 2 - 1, 0))) * 2;\n            }\n        }\n        return res;\n    }\n}\n```
['Java']