i had given the code link below…
can u tell me what is the role of FOR loop in LINE NUMBER 19 and HOW it is working…and Significance.
regards
i had given the code link below…
can u tell me what is the role of FOR loop in LINE NUMBER 19 and HOW it is working…and Significance.
regards
OH SORRY CODE LINK -> https://ide.codingblocks.com/s/101157?_ga=2.218645273.1005782961.1596282910-1868094914.1588256331 PLEASE TELL ME THE SIGNIFICANCE OF FOR LOOP IN LINE NO 19…AND WORKING OF THAT REGARDS…
hi @ManasxCOdE the function basically counts the number of digits in the input number. So we run the for loop for that number of digits in the number.
There is no need to do all this as constraints say that number can have upto 10^18 digits so storing it in a number makes no sense, best to store the number in a string. You can iterate over a string easily.
Also please try to write your own code you’ll learn better.
and also tell me the logic where in that code we are getting the smallest number…
@ManasxCOdE we invert the number if it is greater than or equal to 5, else we dont, so eventually smallest number possible is obtained
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.