Solution1 规律法
时间复杂度 O(n)
主要是比较字符串是否相等
空间复杂度 O(1)
case1: 相等,则必然 -1
case2: 不相等,长度不同,则不然是最长的
case3: 不相等,长度相同,则就是这个长度
Last updated
Was this helpful?
时间复杂度 O(n)
主要是比较字符串是否相等
空间复杂度 O(1)
case1: 相等,则必然 -1
case2: 不相等,长度不同,则不然是最长的
case3: 不相等,长度相同,则就是这个长度
Last updated
Was this helpful?