#1. Java Program To Check Equality Of Two Arrays

preview_player
Показать описание
We will write Java code to find if two one dimensional arrays are equal. For this problem, two arrays will be equal if:-
1. Lengths of both arrays are the same.
2. Both arrays contain the same element in the same order.
I have tried to explain the logic in such a way that will help you to crack interviews for SDET and Test Automation profiles.

Рекомендации по теме
Комментарии
Автор

Excellent Amod. Looking forward for many more questions

rohitcmrec
Автор

Ultimate explanation. I really liked the flowchart way to explain.

ravisen
Автор

very nice sir, thank you please continue with more java problem

raveeshr
Автор

Thanks for sharing, This is helping us a lot. Please create more videos of this sort :)

ranjiniashok
Автор

everyone will understand if u r the trainer.

kirant
Автор

public static boolean arrayCompare(int[] a, int[] b) {

if(a.length != b.length) return false;

Set<Integer> set = new HashSet<>();

for (int i = 0; i < a.length; i++) {
set.add(a[i]);
}
for (int j = 0; j < b.length; j++) {
if (set.add(b[j])) {
return false;
}

}
return true;
}

ashuiet
Автор

What if the order of numbers in arr2 is different... Then what's the approach?

ankitlohia
Автор

what if the arrays weren't sorted ? Did we assume here that the given arrays are sorted

aniketkhandagale
join shbcf.ru