Question: there are 2n+1 charactors which have n paris of same char. how to find out the odd char in Time O(n), Space O(1)?
Algorithom:
Firstly, We should focus on the odd char. If we know which one is odd ,we can give the answer.
Seccondly, Time O(n)--you can only scan the string in O(n), Space O(1), you can use limited space.
We know that all charactors has a int value. Stat the amount of every charactor can find out which char is odd. so we can use a intege matrix, which length is 53 (which contains 26 capital letter and 26 lowercases , plus a blank ). When we scan the string from end to end, we increase the number of char which is now we scan. After that, we scan the matrix, find the odd number which is the result we need.