Yes, that algorithm was formulated as computation of the minimum, but it can be adapted (as said above) to compute the maximum as well using a function LastOne instead of FirstOne with the intended meaning. As far as I can see, the above mentioned modifications in the algorithms for FirstOnePar and FirstOneParOpt would be sufficient to obtain a corresponding algorithm for LastOne.

It is sufficient to note that plan in the mentioned exercise, it is not needed to list the detailed code.

However, the above mentioned algorithm to compute the minimum/maximum is a bad one that cannot be recommended. Note that for an array of size N with integers in the range {-R,..,R-1}, we would need a local array of size R. For 32-bit integers, this is already a challenge. BTW, I see that the algorithm is broken, since a[i] has type int{R} and can be negative, so that occ[a[i]] would fail. Hence, the type of array a should be better nat{R}.