best solution evaaaaa
Intuition\nYay\n\n# Approach\nsimply see if we can include the bridge or not \nwe can include it, if either of i, j lie in the window , else just consider the r
# Intuition\nYay\n\n# Approach\nsimply see if we can include the bridge or not \nwe can include it, if either of i, j lie in the window , else just consider the roads from i to i+1 index. \n\n# Complexity\n- Time complexity:\nO(N^2) (better than it actually, since we are only considering cases when j>i)\n\n- Space complexity:\nO(N)\n\n# Code\n```\nclass Solution {\n    public int[] countOfPairs(int n, int x, int y) {\n        int[] roadCount = new int[n];\n        int tempx=x, tempy=y;\n        x=Math.min(tempx,tempy);\n        y=Math.max(tempx,tempy);\n        for(int i=1;i<=n;i++) {\n            int currRoadCount=0;\n            for(int j=i+1;j<=n;j++) {\n                if(j<x || i>y) {\n                    currRoadCount=j-i;\n                } else {\n                    int d1= Math.abs(x-i) + Math.abs(y-j)+1;\n                    int d2= j-i;\n                     currRoadCount = Math.min(d1,d2);\n                }\n                roadCount[currRoadCount-1]+=2;\n                \n            }\n\n        }\n        return roadCount;\n    }\n}\n```
['Java']