Company: Visa_10june
Difficulty: medium
Longest Common Prefix Between Two Arrays of Numbers You are given two arrays of positive integers, firstArray and secondArray . Write each number in the ordinary way, without leading zeros. A prefix of a number is what you get by keeping one or more of its leading digits, starting from the highest-order digit: 1 , 12 , 123 , 1234 and 12345 are the prefixes of 12345 . A common prefix of two numbers is a prefix of both, so the longest common prefix of 565359 and 565354 is 56535 , while 123 and 456 share no common prefix at all. Take one number from firstArray and one number from secondArray . Over every such pair, report the length of the longest common prefix that any pair achieves. If no pair shares even its first digit, report 0 . Input Format The first line contains a single integer n — the length of firstArray . The second line contains n space-separated integers firstArray[0] ... firstArray[n-1] . The third line contains a single integer m — the length of secondArray . The fourth l