Chewbacca and Number. It passes only one test case and i want to solve this problem throught this approach .I has already solved throught char array .My solution passes only one test case how can make it correct it. Ca u help me out?

Some hints: to get to the correct approach

  1. since a check on 1st pos is done if 1st pos has 9 it is not changed, u have to keep that case in mind
    think of how would u see wether this is the 1st positioned number when u are taking the no. from the right
    {hint: put a if condn (num/10 == 0) }

  2. reverse o/p is required, think of storing it in a vector, reversing the final output

  3. The conversion method is correct, just the o/p has to be reversed and the corner case of 9 in 1st position

if i decalare a reverse function can it work or not.Can you code it?

Yes, u can put the values in the vec and then use inbuild reverse function.
Please try to code it once, i can rectify the errors.
else u`ll not learn.
Try using vector

okk i will try to code .

1 Like

could u do the problem ??? Please ask in case u have further doubts…!..

PS. it will be marked answered soon.

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.