[Java] Prefix Sum
\nclass Solution {\n    public int[] findDiagonalOrder(List<List<Integer>> nums) {\n        int m = nums.size(), maxSum = 0, size = 0, index = 0;\n        List<
```\nclass Solution {\n    public int[] findDiagonalOrder(List<List<Integer>> nums) {\n        int m = nums.size(), maxSum = 0, size = 0, index = 0;\n        List<Integer>[] map = new ArrayList[100001];\n        for (int i = 0; i < m; i++) {\n            size += nums.get(i).size();\n            for (int j = 0; j < nums.get(i).size(); j++) {\n                int sum = i + j;\n                if (map[sum] == null) map[sum] = new ArrayList<>();\n                map[sum].add(nums.get(i).get(j));\n                maxSum = Math.max(maxSum, sum);\n            }\n        }\n        int[] res = new int[size];\n        for (int i = 0; i <= maxSum; i++) {\n            List<Integer> cur = map[i];\n            for (int j = cur.size() - 1; j >= 0; j--) {\n                res[index++] = cur.get(j);\n            }\n        }\n        return res;\n    }\n}\n```
['Java']