Whats the best way to compare 2 arrays of different sizes to find the first similar element starting from the back?