Sorting a binary 2D matrix?

前端 未结 6 1253
伪装坚强ぢ
伪装坚强ぢ 2021-02-09 13:06

I\'m looking for some pointers here as I don\'t quite know where to start researching this one.

I have a 2D matrix with 0 or 1 in each cell, such as:

  1         


        
6条回答
  •  后悔当初
    2021-02-09 13:57

    Basic algorithm:

    1. Determine the row sums and store values. Determine the column sums and store values.
    2. Sort the row sums in ascending order. Sort the column sums in ascending order.

    Hopefully, you should have a matrix with as close to an upper-right triangular region as possible.

提交回复
热议问题