Description
Submission
class Solution { public: vector<int> luckyNumbers (vector<vector<int>>& matrix) { int m = matrix.size(); int n = matrix[0].size(); vector<int> rowMin(m, INT_MAX); vector<int> colMax(n, 0); for(int i = 0; i < m; ++i) { for(int j = 0; j < n; ++j) { rowMin[i] = min(matrix[i][j], rowMin[i]); colMax[j] = max(matrix[i][j], colMax[j]); } } vector<int> rets; for(int x: colMax) { for(int y: rowMin) { if(x == y) rets.push_back(x); } } return rets; } };