Code Arcade practice on CodeSignal - Python and Java

preview_player
Показать описание
Struggling with the Are Similar? problem in the Code Signal arcade
Рекомендации по теме
Комментарии
Автор

How about sort both arrays then check if it's true?

sergiodamasceno
Автор

Do a For loop to iterate up to the length of array a. (Both arrays are the same length.) In each iteration, if a[i] is not equal to b[i], push both a[i] and b[i] into a new array, r (declared at the start of the loop). After the loop finishes, Return the logical AND of two tests: length of r < 5, and length of a new array containing only unique elements in r < 3.


The first test determines if there are only two mismatched elements or zero. The second test determines if there are only two unique mismatched elements or zero. If both tests return True, the two arrays are similar.

TheRobertVFrazier
welcome to shbcf.ru