1. Engineering
  2. Computer Science
  3. write a python function fixeddist that takes two lists a...

Question: write a python function fixeddist that takes two lists a...

Question details

Write a Python function fixed_dist that takes two lists a and b, each of which is sorted in non-decreasing order, and takes a number d, and returns a pair of values (a[i], b[j]) such that a[i] - b[j] == d, or returns None if no such pair exists. It should run in time O(n) where n = sum of the lengths of the two lists. For example, fixed_dist([1, 6, 14, 22, 29], [3, 10, 13, 17, 19, 21], 5) should return (22, 17)

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution