Pls share optimal solution


this is my solution…it passes all test cases…pls share if any optimised solution exists for this question

@Garvit012 hey check this out:

isn’t it working the similar way my code is working
there is a check CB function
instead of isvisited() i am marking numbers as X for multiple digit numbers and I for single digit numbers

@Garvit012 yeah this is the best approach for this question only.