先Mark一下参考资料:https://blog.csdn.net/devnn/article/details/82716447
春节无聊的时候做了两题队列和栈相关的基础题目,主要考察的是对Deque的理解和使用,有现成封装好的接口直接调用即可,没有骚操作。
今天复工第一天,照例提前1小时来公司刷题。
今天做的是求数组中字符串的最长公共前缀:https://leetcode-cn.com/leetbook/read/array-and-string/ceda1/
2个关键点总结一下:
1.Java最重要的,对于数组本身一定要判空;
2.当前N个字符的公共前缀为空时,已经不需要判断第N和第N+1个,可以直接返回空;
用到的String的2个方法:
1.public String substring(int beginIndex, int endIndex)
提取字符串中介于两个指定下标之间的字符串:https://www.runoob.com/java/java-string-substring.html
2.public char charAt(int index)
返回指定索引处的字符:https://www.runoob.com/java/java-string-charat.html
网友评论