Given a very large list A, C, A, D, A, B, C, D, A, C
How can I get the counts of the current element and the next efficiently? Something like:
AC, CA, AD, DA, AB, BC, CD, DA, AC
A : {A:0, B:1, C:2, D:1}
B : {A:0, B:0, C:1, D:0}
C : {A:1, B:0, C:0, D:1}
D : {A:2, B:0, C:0, D:0}
Or if I were to print it, it would produce:
A B C D
A 1 2 1
B 1
C 1 1
D 2