Last Occurance Recursion

why is the test case failing please let me know?