groups to store lists of elements, keyed by their diagonal identifier (sum of row and column indices).nums from the last row to the first row.groups.ans to store the final diagonal order.groups in ascending order, appending each group's elements to ans.ans.