The function basically counts the total number of elements in array A which differ from the elements of array B at the same index.
Example: A = [1,2,3,4,5] and B = [2,2,3,4,6] , The answer for these two arrays will be 2. At index 0 the element differs and at index 4 the element differs.
Time Complexity: The for loop will run till n which is the total number of number of elements in the array. Rest of the operations are of unit 1 time complexity which are constant. So the overall time complexity will be O(n).
Happy Learning!
Get Answers For Free
Most questions answered within 1 hours.