I’m unable to understand the question, please explain me this with a solution
Can't undestand the question
hello @shazanahmed1
in this question u need to generate minimum number from given number by flipping digits of the given number.(i,e if digit is t then u can flip it with 9-t
note : the generate number should not have leading 0’s
for example -> if n = 987 then u cannot replace 9 with 0 becuase then it will give leading 0.
the idea is read the given number as string (say s) .
if left most character is ‘9’
then leave the leftmost character as it is and for other characters simpl replace s[i] with min(s[i],‘9’-s[i])
else:
for each i replace s[i] with min(s[i],‘9’-s[i])
print s
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.