left and right.
A leading part of a number is the number formed by one or more of its first digits, read from the left. For example, 3051 has leading parts 3, 30, 305 and 3051, while 51 is not one of them.
Pick one number from left and one from right and find the longest leading part they share. Return the greatest length (in digits) of such a shared leading part over all possible pairs, or 0 if no pair shares one.
Pairs are only formed across the two lists; numbers in the same list are never compared.left=[47, 4801, 9], right=[480, 470] → 3
4801 and 480 both start with 480, which is three digits. That beats 47 and 470 (two digits).
left=[12, 34], right=[56, 21] → 0
No pair starts with the same digit, so the answer is 0. Numbers within the same list are never compared to each other.
left=[7], right=[7] → 1
left=[47, 4801, 9], right=[480, 470]
3
Run checks the first 3 tests in your browser. Submit checks all 118 tests on the server, hidden ones included.