commit e4f8c09e23ae3fba89856db49b5ef3dc9d7dc8e7
parent a012edcff84a22149474cc4d9601b03390a60d44
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Fri, 16 Aug 2024 19:00:08 +0200
Daily Problem
Diffstat:
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/Problems/0624.cpp b/Problems/0624.cpp
@@ -0,0 +1,16 @@
+class Solution {
+ public:
+ int maxDistance(vector<vector<int>> &arrays) const {
+ int mini = arrays[0].front();
+ int maxi = arrays[0].back();
+ int res = 0;
+
+ for (int i = 1; i < size(arrays); i++) {
+ res = max({res, arrays[i].back() - mini, maxi - arrays[i].front()});
+ mini = min(mini, arrays[i].front());
+ maxi = max(maxi, arrays[i].back());
+ }
+
+ return res;
+ }
+};
diff --git a/README.md b/README.md
@@ -427,6 +427,7 @@ for solving problems.
| 0621 | Medium | [Task Scheduler](Problems/0621.cpp) |
| 0622 | Medium | [Design Circular Queue](Problems/0622.cpp) |
| 0623 | Medium | [Add One Row to Tree](Problems/0623.cpp) |
+| 0624 | Medium | [Maximum Distance in Arrays](Problems/0624.cpp) |
| 0626 | Medium | [Exchange Seats](Problems/0626.cpp) |
| 0627 | Easy | [Swap Salary](Problems/0627.cpp) |
| 0629 | Hard | [K Inverse Pairs Array](Problems/0629.cpp) |