I am working on a project where at one point I am stuck.
My question is for example I have the following 2D array containing 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 contained 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 as to what I have to do to achieve this goal?
Easier to draw than to explain…
update:
And now, with some real code: