This is my code for the Chef and Digits Jump problem (Graph Theory Basics —DSA Learning Series) https://www.codechef.com/viewsolution/36091013 …I have checked all previous post on it and tried all the test cases .All of them executed perfectly but it is still giving a wrong answer.

Brief explanation of my approach: I have created a Adjacency list using Array of ArrayList.The index of the array denotes a digit.If a digit is found to repeat in the sequence it is added to the ArrayList object at that index.

After creating the adjacency list I made a bfs traversal on the list slightly in a modified way.

(Note:–While creatinfg the adjacency list I havent taken care of the i+1 position and i-1 position.This has been taken care while performing bfs.)

While visiting each position I added the i+1 and i-1 positions to queue to be visited if not already.

And finally when i get the last position i am displaying the answer.

That was my approach…

Here is the problem link:—https://www.codechef.com/LRNDSA08/problems/DIGJUMP

Please help me out with this problem

(Code isnt too complicated )