- How to find the common element of two arrays in C?
- How do you check if two arrays have the same elements in the same order?
How to find the common element of two arrays in C?
i) Use two index variables i and j, Initialized them with 0. ii) If arr1[i] is smaller than arr2[j] then increment i. iii) If arr1[i] is greater than arr2[j] then increment j. iv) If both are same then print any of the array value and increment both i and j.
How do you check if two arrays have the same elements in the same order?
The Arrays. equals() method checks the equality of the two arrays in terms of size, data, and order of elements. This method will accept the two arrays which need to be compared, and it returns the boolean result true if both the arrays are equal and false if the arrays are not equal.