部分整理自Stack Overflow:
Java String:
- length()
- indexOf()
- isEmpty()
- charAt(i)
- startsWith() — used for checking prefix of a String, returns a boolean value true or false based on whether the specified string is prefix of the particular String or not.
- Substring(x,y)
Leetcode 14 — longest common prefix:
method1: horizontal scanning LCP(S1…Sn)=LCP(LCP(LCP(S1,S2),S3),…Sn).
method2: vertical scanning
method3: divide and conquer ?
method4: binary search 先找到最短的string字符数minLen,二分法, 先看0~minlen/2 个字符是否都一样,若一样则prefix字符数+1再查,否则prefix字符数-1再查
Method5: Arrays.sort方法对对象数组按照自然顺序进行排序,比较第一个和最后一个string
Java String
原文:https://www.cnblogs.com/rySZ/p/10546256.html