lonngest substring dog implementation