Efficient way to compute first non-recurring character in string