[
greedy
]
BinarySearch 0833 Largest Pair of Points
Problem statement
https://binarysearch.com/problems/Largest-Pair-of-Points/
Solution
We can notice that we need to make largest (values[i] - nums[i]) + (values[j] + nums[j])
, so create arrays X
and Y
first.
Complexity
It is O(n)
for time and space.
Code
class Solution:
def solve(self, A, B):
X = [j - i for i, j in zip(A, B)]
Y = [i + j for i, j in zip(A, B)]
return max(X) + max(Y)