Gajendra

The by sage Agastya cursed King Indradyumna had to be born as an elephant, Gajendra.

The Gandharva Huhu was cursed by Sage Devala to be born as a crocodile.

When Gajendra came near the pond in which Huhu lieved Huhu attacked him. Gajendra prayed to Vishnu and was saved. Huhu was released from his curse and went back to heaven.

To read the story visit
http://hindumythologyforgennext.blogspot.com/2012/04/gajendra-elephant.html

When his merits were exhausted he fell back to earth. For to go back to heaven he had to find someone who could remember his good deeds.

To read the story visist
http://hindumythologyforgennext.blogspot.com/2014/09/indradyumna.html

I cannot say with certainty whether it is actually the same king, but I have found the variant of the story.