00:01
Hello student, here in python program we have to find the index of the last occurrence of an element m in the array of the size n consisting of the integer.
00:13
We can use the following algorithm.
00:15
Initialize the variable last underscore occurrence to the minus 1.
00:20
Iterate over the array from the end to the beginning.
00:24
If the current element is equal to m then set last occurrence to the current element and return the value of the last occurrence.
00:35
So in this way we can find the last occurrence.
00:38
Now i have written here the python code.
00:43
So here i have taken the function name find underscore last underscore occurrence.
00:50
Here i am passing two arguments array of size m.
00:55
So finding the index of the last occurrence of the element m in the array if it exists otherwise represents minus 1.
01:02
Argument array a list of the integer m is the element to search for.
01:08
So here returns the index of the last occurrence of the element m in the array if it exists otherwise it is minus 1.
01:18
So last underscore occurrence equal to minus 1 we set and for array i in the range minus 1 minus 1 minus 1 because we are starting from the last that's why minus 1 we are taking...