Minimum Distance Between People and Cakes

Asked at Google · Coding & Leetcode-style Questions · Difficulty: Medium

Write a method to return the minimum distance between any person and any cake. Inputs are two arrays: one integer array representing people's positions and another representing cakes' positions. Both arrays are sorted in ascending order. Output an integer indicating the minimum distance. Assume people and cakes are on the same dimension. Implement a solution with O(N) time complexity.

Loading the problem…