Skip to content

Commit b9ebf93

Browse files
committed
Time: 235 ms (49.06%), Space: 107.8 MB (69.81%) - LeetHub
1 parent 4602a5a commit b9ebf93

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
int maxDistance(vector<vector<int>>& arrays) {
4+
5+
int left = arrays[0][0], right = arrays[0].back(), ans = 0;
6+
7+
for(int i = 1; i < arrays.size(); i++)
8+
{
9+
ans = max(ans, max(abs(arrays[i][0] - right), abs(arrays[i].back() - left)));
10+
left = min(left, arrays[i][0]);
11+
right = max(right, arrays[i].back());
12+
}
13+
14+
15+
return ans;
16+
}
17+
};

0 commit comments

Comments
 (0)