
									 Problem
								
								
									 Solution
								
								
									 Submissions
								
								
							Check if Two Arrays are Equal
								Certification: Basic Level
								Accuracy: 0%
								Submissions: 0
								Points: 8
							
							Write a JavaScript program to determine if two arrays are equal. Two arrays are considered equal if they contain the same elements in the same order. The function should handle arrays of different data types including numbers, strings, and nested arrays.
Example 1
- Input: arr1 = [1, 2, 3], arr2 = [1, 2, 3]
 - Output: true
 - Explanation: 
- First array is [1, 2, 3]. 
 - Second array is [1, 2, 3]. 
 - Both arrays have same length (3). 
 - All corresponding elements are equal. 
 - Therefore, arrays are equal.
 
 - First array is [1, 2, 3]. 
 
Example 2
- Input: arr1 = [1, 2, 3], arr2 = [1, 3, 2]
 - Output: false
 - Explanation: 
- First array is [1, 2, 3]. 
 - Second array is [1, 3, 2]. 
 - Both arrays have same length (3). 
 - Elements at index 1 and 2 are different. 
 - arr1[1] = 2, arr2[1] = 3 (not equal). 
 - Therefore, arrays are not equal.
 
 - First array is [1, 2, 3]. 
 
Constraints
- 0 ≤ arr1.length, arr2.length ≤ 1000
 - Arrays can contain numbers, strings, or nested arrays
 - Comparison should be done element by element
 - Arrays must have same length and same order to be equal
 - Time Complexity: O(n) where n is the length of arrays
 - Space Complexity: O(1)
 
Editorial
									
												
My Submissions
										All Solutions
									| Lang | Status | Date | Code | 
|---|---|---|---|
| You do not have any submissions for this problem. | |||
| User | Lang | Status | Date | Code | 
|---|---|---|---|---|
| No submissions found. | ||||
Solution Hints
- First check if both arrays have the same length
 - Iterate through both arrays simultaneously
 - Compare each pair of corresponding elements
 - Handle different data types appropriately
 - Return false immediately if any pair doesn't match