This question beautiful graph, i solved it using Java, in C++ i can’t figure out what is the issue. i get into infinite loop. Same solution in Java got AC. please help me out. Here is the link for my solution:
https://ide.geeksforgeeks.org/2tZ8Zhcb4N
Answer to the given test case:
0
3
4
0
6
8
0
16
296595689
0
0
80
