摘要:
Java的字符串也很强大。public class Solution { public int lengthOfLastWord(String s) { if(s.length() == 0) return 0; String[] str = s.trim(... 阅读全文
posted @ 2015-04-03 18:22
Pickle
阅读(135)
评论(0)
推荐(0)
摘要:
Java对二进制的支持还是比较好的,用上BIgInteger连溢出都不用考虑了。public class Solution { public String addBinary(String a, String b) { java.math.BigInteger ia = new java.m... 阅读全文
posted @ 2015-04-03 18:20
Pickle
阅读(158)
评论(0)
推荐(0)
摘要:
判断是不是符合数独的规则。数独的规则:每一行每一列不能有重复的数字,每一个3X3方格中不能有重复的数字,但是这个题中可以为空即都是'.'。 (要养成良好的编程习惯啊,要不一点低级错误不容易发现,浪费生命!)public class Solution { public boolean isVal... 阅读全文
posted @ 2015-04-03 14:09
Pickle
阅读(262)
评论(0)
推荐(0)
摘要:
自从JavaAPI&RegExp用熟练了之后就变得越来越任性越来越懒了):public class Solution { public int strStr(String haystack, String needle) { return haystack.indexOf(ne... 阅读全文
posted @ 2015-04-03 10:52
Pickle
阅读(140)
评论(0)
推荐(0)
摘要:
线性表的删除操作,这里可以用ArrayList实现简单的完成。(偷懒)public class Solution { public int removeElement(int[] A, int elem) { ArrayList arr = new ArrayL... 阅读全文
posted @ 2015-04-03 10:42
Pickle
阅读(176)
评论(0)
推荐(0)
摘要:
删除数组里重复的元素,返回数组的元素个数。可以利用set集合元素不重复的特点来保存。public class Solution { public int removeDuplicates(int[] A) { java.util.SortedSet set = ... 阅读全文
posted @ 2015-04-03 10:31
Pickle
阅读(144)
评论(0)
推荐(0)
浙公网安备 33010602011771号