Do you know Intersection between Array's? in Tamil | Java | MNC | DinaTechy

  Рет қаралды 23

DinaTechy

DinaTechy

Күн бұрын

Intersection: We first add all elements of the first array to a set and then check if elements of the second array are present in that set. Common elements are added to the intersection set.
This Java program is designed to find the intersection of two arrays. The intersection of two arrays consists of elements that are present in both arrays. The program iterates through the elements of both arrays and stores the common values in a new array, which is then printed as output.
Steps of the Program:
Input Arrays:
1. Two arrays are declared: arr1 and arr2.
2. The goal is to find the common elements between arr1 and arr2. In this case, the common elements are 5 and 3
Result Array Initialization:
1. A new array resultArr is created to store the common elements (i.e., the intersection). The size of this result array is set to half of the combined length of the two input arrays, assuming the worst-case scenario where all elements in one array are also present in the other.
Finding Intersection:
1. Two nested for-each loops are used to compare each element in arr1 with each element in arr2.
2. The program checks if an element from arr1 matches an element from arr2. If a match is found, it stores the value in the resultArr array.
Printing the Result:
1. After finding the common elements, the program prints the resultArr array. The check if(a != 0) ensures that only non-zero values are printed, as unused elements in resultArr will remain 0.
Telegram - t.me/+lhWGhenJ...
Thanks for watching the video Guys.
Like and Share Guys.
Subscribe and Support Guys.
#codingtamilan #codingintamil #java #javainterviewquestionsandanswers #javainterviewquestionsandanswersforfreshers #javainstitute #javaprogramming #javainterviewquestionsandanswersforexperienced #dynamicprogramming #dynamicprogram #dynamic #1000subscriber #100dayschallenge #100daystransformation #100daysofcode #100days #zohorecruitment #zohospecialist #zoholatestprogramming #zohotutorial #zohojobs

Пікірлер
إخفاء الطعام سرًا تحت الطاولة للتناول لاحقًا 😏🍽️
00:28
حرف إبداعية للمنزل في 5 دقائق
Рет қаралды 80 МЛН
How it feels when u walk through first class
00:52
Adam W
Рет қаралды 21 МЛН
3.7 Suzuki Kasami Algorithm Part 1 in Tamil
18:49
BECAUSE
Рет қаралды 20 М.