smallest_common
to a high value (e.g., 10) which is outside the range of digits.nums1
and for each digit, check if it is present in nums2
. If it is, update smallest_common
to the smaller of its current value and the digit.smallest_common
is less than 10, return smallest_common
as the result.nums1
and nums2
separately.