I have a 2-dimensional array which has rows of different lengths. I want to write a method that returns a new array which consists of the maximum elements of columns. If this was a simple n x m array, it would be easy but since the rows are variable length, I can't come up with a solution to account for the different number of elements in columns.

EDIT: I realized now that the first thing to do is finding the row with maximum number of elements since that defines the size of the new array. From there.. should probably take the elements of a row and compare them with the elements at the same position in the new array. And do this with every row. Then it doesn't matter how short the other rows are. Am I on the right way?