[
array
two pointers
]
BinarySearch 1002 Dropped Sensor Metric
Problem statement
https://binarysearch.com/problems/Dropped-Sensor-Metric/
Solution
Equal to Leetcode 1826 Faulty Sensor
Complexity
It is O(n)
for time and space.
Code
class Solution:
def solve(self, A1, A2):
n, found = len(A1), []
for i in range(n):
if A1[i] != A2[i]: break
if A1[i:-1] == A2[i+1:]: return A2[i]
if A2[i:-1] == A1[i+1:]: return A1[i]