![]() |
VOOZH | about |
Given two arrays, a[] and b[] of equal length. The task is to determine if the given arrays are equal or not. Two arrays are considered equal if:
Examples:
Input: a[] = [1, 2, 5, 4, 0], b[] = [2, 4, 5, 0, 1]
Output: trueInput: a[] = [1, 2, 5, 4, 0, 2, 1], b[] = [2, 4, 5, 0, 1, 1, 2]
Output: trueInput: a[] = [1, 7, 1], b[] = [7, 7, 1]
Output: false
Table of Content
The basic idea is to sort the both arrays. Compare the arrays element by element one by one if all are same then it is equal array otherwise it is not.
true
Use of a hash map to count the occurrences of each element in one array and then verifying these counts against the second array.
true