java solution || 100% fast
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       if(x>y)return countOfPairs(n, y,x);\n       long[]ans = new long[n];\n\n       List<Pair>intervals = new ArrayList<>();\n       for(int i=1;i<=n;i++){\n\n           int shortcut = 1+Math.abs(i-x);\n\n           if(y-i > shortcut){\n               if(y<n)intervals.add(new Pair(shortcut+1, shortcut+n-y));\n\n               int diff = y-i-shortcut;\n\n               int step = diff/2;\n\n               if( (diff&1) == 1)step++;\n\n               intervals.add(new Pair(shortcut, shortcut+step-1));\n               intervals.add(new Pair(1, y-step-i));\n           }else{\n               intervals.add(new Pair(1, n-i));\n           }\n\n\n       }\n\n      long[]temp = new long[n+1];\n      for(Pair p:intervals){\n          temp[p.left]++;\n          temp[p.right+1]--;\n      }\n\n      long sum = 0;\n      for(int i = 1;i<=n;i++){\n          sum += temp[i];\n          ans[i-1] = sum*2;\n      }\n       return ans;\n    }\n\n}\nclass Pair{\n    int left, right;\n    public Pair(int left, int right){\n        this.left = left;\n        this.right = right;\n    }\n}\n```
['Java']