How to transpose List?

前端 未结 10 681
温柔的废话
温柔的废话 2021-01-01 17:59

I have a following ArrayList,

[Title,Data1,Data2,Data3]
[A,2,3,4]
[B,3,5,7]

And I would like to convert this one like this,



        
10条回答
  •  礼貌的吻别
    2021-01-01 18:55

    Check whether all lists have the same size.

    Place the informations in a Matrix (List with List elements, for example) to get the number of lists and size of a list.

    Create a new Matrix with the rotated size informations. (3x4 to 4x3)

    Implement 2 For loops and place the elements into the new matrix.

提交回复
热议问题