q1. convert n to string s then find its next permuatation using stl function then convert back into integer if it is within range return otherwise return -1
For Question 2 its simple just explore all the possible digits sum and their power from 1-5 and stored it then just check the condition and save the number
For Question 2 its simple just explore all the possible digits sum and their power from 1-5 and stored it then just check the condition and save the number