Where is it going wrong (chewbacca number)

mujhe question thik se samaj nhi aaya lekin itna samaj aaya h ki least number output krana h saari digits m se aur number se pehle zero nhi hona chahiye

isi ke according program h

basically you have to invert the digits to make it smaller but no leading zeroes
for ip 999 ur op 999 but ans 900 check it @anujsharmabadboy

@vatsal38
lekin aise sample input 4545 h par uska output toh 4444 h

@anujsharmabadboy yes

if at first place its 9 then u have to take care

samaj nhi aaya bhai
kuch example dekar samjhao na

for every digit if its greater than equal to 5 you have to do 9-digit .
only corner case if first digit 9 like 954 u cant make it 044 as it contains leading zeroes so ans is 944
@anujsharmabadboy

examples
999 900
957 942
454 444
1234 1234
9021 9021
7777 2222

acha agar digit greater than 5 h toh 9 - digit (except for digit 9 itself)
aur digit less tha 5 ha toh leave as it is ??
asia hi h

yup and 9 agar first place pe hai tohi usse nahi lena
909 ans is 900

hmmm
lekin yeh jo barrier h 5 yeh question m kaha given h
apko kese pta chala ??

logically socho 9-t given a question mein and minimum banana hai
so agar 4 hai toh 9-4=5 badha hai toh isse invert karne ka koi fayda nah ab agar t=5 hai toh 9-5=4 which is less. aise sochai

okay bhai
ho gya submit

np just mark it as resolved @anujsharmabadboy :smiley:

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.

bhai jab hi kr diya tha