Identity Crisis
MediumAcc. 91.4%
+35 XP 15
Perfectly Mirror
Two arrays are identical if they have the same number of elements and every element at index i is the same in both.
The Assignment
Your function receives arr1 and arr2.
- First, check if the lengths are different. If so, print false and exit.
- Use a loop to compare
arr1[i]witharr2[i]. - If any mismatch is found, print false and exit.
- If the loop finishes, print true.
01EXAMPLE 1
Input
arr1=[1, 2], arr2=[1, 2]Output
trueExplanation: Identical.
Constraints
- Return a boolean string.
- Linear O(n) scan.
ArraysLogic
JavaScriptSystem handles I/O — write your function only
Loading...
2 Hidden
Input Arguments
arr1[1,2,3]
arr2[1,2,3]
Expected Output
true
Click RUN to test your solution