FastPrepMaximum Common Decimal Prefix Across Arrays

Maximum Common Decimal Prefix Across Arrays

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA
Learn

Problem statement

You are given two arrays of positive integers, first and second.

Choose one value from each array and compare their ordinary decimal representations. Return the maximum common-prefix length over every cross-array pair.

Function

maximumCommonDecimalPrefix(first: int[], second: int[]) → int

Examples

Example 1

first = [12345,9012]second = [12222,1,123902]return = 3

12345 and 123902 share prefix 123, of length three.

Example 2

first = [7,80]second = [6,90]return = 0

No cross-array pair starts with the same digit.

Constraints

  • 1 <= first.length,second.length <= 100000
  • 1 <= value <= 1000000000

More ZipRecruiter problems

See ZipRecruiter hiring insights
public int maximumCommonDecimalPrefix(int[] first, int[] second) {
    // Write your code here.
}
first[12345,9012]
second[12222,1,123902]
expected3
Checking account…