Can we solve this question recursively, if yes than how please give the hint?

https://mycode.prepbytes.com/problems/arrays/FAVOURITES