-
Notifications
You must be signed in to change notification settings - Fork 476
Expand file tree
/
Copy path1380.cpp
More file actions
27 lines (25 loc) · 677 Bytes
/
1380.cpp
File metadata and controls
27 lines (25 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Solution
{
public:
vector<int> luckyNumbers (vector<vector<int>>& A)
{
int r = A.size(), c = A[0].size();
vector<int> res;
for (int i = 0; i < r; i++)
{
pair<int, int> t = {INT_MAX, -1};
for (int j = 0; j < c; j++)
if (A[i][j] < t.first) t = {A[i][j], j};
bool flag = false;
for (int j = 0; j < r; j++)
{
if (A[j][t.second] > t.first)
{
flag = true; break;
}
}
if (!flag) res.emplace_back(t.first);
}
return res;
}
};