Solution for beginner | nested loop | O(n^2) | Java
Please Upvote if you liked it \uD83D\uDE4F\uD83D\uDE4F\uD83D\uDE4F\n\nJust add the difference between the indices with the ball\n\n\n        int ans[] = new int
# Please Upvote if you liked it \uD83D\uDE4F\uD83D\uDE4F\uD83D\uDE4F\n\nJust add the difference between the indices with the ball\n\n```\n        int ans[] = new int[boxes.length()];\n        for(int i = 0; i < boxes.length(); i++){\n            for(int j = 0; j < boxes.length(); j++){\n                if(boxes.charAt(j) == \'1\')\n                    ans[i] += Math.abs(j - i);\n            }\n        }\n        return ans;\n\n```
['Java']