string and pattern algos