Find longest duplicated substring | Google Interview Question