书法字典:https://www.shufadict.com

Shortest distance between two arrays

Given two sorted array in non-descending order, each contains positive integers
The distance is define as following
pick up a number from each array, compute their difference
return the shortest distance among them-that's the distance between the two arrays
example
int[] a = {1, 3, 5, 7 , 9} ;
int[] b = {2, 4, 8} ;
The result is 1

 

Code

 

posted on 2009-06-07 16:07  翰墨小生  阅读(382)  评论(0编辑  收藏  举报

导航

书法字典:https://www.shufadict.com