Company: Rubrik SE Intern_2nov
Difficulty: medium
Table Shrinker Problem Description Junior codester, Fyodor, recently got quite fascinated by reducing the representation of numeric information. Having explored various encoding approaches known as "alpha", "beta", and "theta", Fyodor has chosen to pioneer another novel approach, dubbed "omega". To showcase his approach, he has chosen a grid of positive values structured in n horizontal lines and m vertical columns. Fyodor's favorite feature about his method is preserving numeric ordering both horizontally and vertically. To clarify; if a number at position (i, j) in the original grid is smaller than the value at position (i, k) within row i, the same must also hold true for the compressed algorithm's resulting "omega" table. Equal values must stay equal in relative positions, too. The same rules apply vertically—numbers remain similarly ordered within columns. Fyodor realizes bigger numbers occupy extra storage. Thus, his algorithm's efficiency hinges on making the largest number appe