Uber OA Question

Hi all,

Was curious if anybody could assist me in understanding an optimal solution to this question. Decided to try Trie implemenation but was timing out on larger test cases. Thanks!

Given two arrays of stricly integers, arr1 and arr2, find the length of the longest common prefix of any pair of numbers
from the two arrays.

Example:

  • arr1 = [123, 4, 5, 955]
  • arr2 = [12345, 63, 95, 2]
  • Solution = 3

UPDATE

I was able to find the problem and understand the correct solution. Thanks for the help everyone!

Comments (8)