3 implemenation for finding dup char