Solution is not up to mark


setter’s solution is not the solution i will recommend to someone.


I find editorial solution elegant and optimized.
How are you planning to handle when, answer exceeds integer/long long range. Using string modular divison is one path. But, that is not required in this problem.
Also, if you plan to do normal bfs, this solution is more space optimized than simple bfs. As we are not keeping duplicates.
Third using states, is an excellent approach. To avoid string modulation. And to form answer from parent, it is required to keep one ans in one state and that too the minimum/optimized/best/first seen/shortest one. That’s why visited is required to clearly form answer from parent array of the states.