Non-DP O(n*256)

programming
Tags: #<Tag:0x00007f1827d36df0>

#1

The basic idea is that when a character appears more than 1 time, check if there is any other
character which also appeared more than 1 time, and the first occurance of the character should
be less than first occurance of this one.
e.g. aabb or abab when b occured second time, we already have a 2 times, and the first occurance
of a is 0, and first occurance of b is 1, so a appeared before b
For abba, when a appeared second time we have have b appeared 2 times already, but first occurance
of b is 1 which is greater than the first occurance of a, so it is not answer.
For same characters we will check if a character appears more than 2 times, then it will be always true
e.g. aaa, here a[0]a[1]==a[1]a[2].