If a permutation is lexicographically highest, then I will eventually become -1. so at the return statement, there should be i < 0, instead of i >=0.