摘要: Find the substring of length 3 which is present in the reverse order from the string.Ex: if the string is abcdcba (cba is the reverse of abc) so we should return cba.And was asked to improve upon the complexity.A:1. 遍历字符串,取长度为3的子字符串,然后生成hash表1;2. 反转字符串先;3. 再遍历字符串,取长度为3的子字符串,得到hash值,然后查表1;时间复杂度:O(n) 阅读全文
posted @ 2011-11-24 13:48 百分百好牛 阅读(175) 评论(0) 推荐(0) 编辑