Hi All. I am working on a project where at one point i am stucked. my Question is for example i have the following 2D array containg 3 different integers..

2 2 2 2 1

1 2 2 2 1

3 3 2 3 2

3 1 3 3 1

1 1 2 3 1

1 3 1 3 3

what i want is to find the longest adjacent elements chain of array of any number containing in the array. like in the above array the longest chain is of digit 2.

2 2 2 2

2 2 2

2

Can anyone just Guide me what i have to do for Achieving this Goal. Thanks.