Vertical Profiling with const input
Still a O(RC) but will less operations than required if modifying the matrix.Code

Still a O(RC) but will less operations than required if modifying the matrix.


# Code
```cpp []
class Solution {
public:
    int largestSubmatrix(const std::vector<std::vector<int>>& matrix) {
        const size_t R = matrix.size();
        const size_t C = matrix[0].size();

        int max_area = 0;

        std::vector<int> heights(C, 0);
        std::vector<int> sorted_height;
        sorted_height.reserve(C);

        for (size_t r = 0; r < R; ++r) {
            for (size_t c = 0; c < C; ++c) {
                if (matrix[r][c]) {
                    ++heights[c];
                } else {
                    // Reset cumulative count.
                    heights[c] = 0;
                }
            }
            sorted_height = heights;
            std::sort(sorted_height.begin(), sorted_height.end(), std::greater<int>());

            for (size_t c = 0; c < C; ++c) {
                if (sorted_height[c]) {
                    const int area = (c + 1) * sorted_height[c];
                    max_area = std::max(max_area, area);
                } else {
                    break;
                }
            }
        }

        return max_area;
    }
};
```
['C++']