• + 1 comment

    but when you find max value for a certain position and flip the necesary row/col this may alter another already sorted col/row... so its more complex to just find max values and add it to total. Look at this example: original matrix:

    [112 42 83 119 ]

    [56 125 56 49 ]

    [15 78 101 43 ]

    [62 98 114 108 ]

    max A: 119 reversed row: 0

    [119 83 42 112 ]

    [56 125 56 49 ]

    [15 78 101 43 ]

    [62 98 114 108 ]

    max B: 114 reversed row: 3 reversed col: 1

    [119 114 42 112 ]

    [56 78 56 49 ]

    [15 125 101 43 ]

    [108 83 98 62 ]

    max C: 56 Not necesary flip

    [119 114 42 112 ]

    [56 78 56 49 ]

    [15 125 101 43 ]

    [108 83 98 62 ]

    max D: 125 reversed col: 1 <<<--- HERE

    [119 83 42 112 ]

    [56 125 56 49 ]

    [15 78 101 43 ]

    [108 114 98 62 ]

    --final matrix--

    [119 83 42 112 ]

    [56 125 56 49 ]

    [15 78 101 43 ]

    As you can see, when i reversed column 1 to get value 125 on D, it alter B =114

    ee, when i reversed column 1 to get value 125 on D, it alter B =114