- 博客(6)
- 收藏
- 关注
原创 KMP算法
classSolution{publicintstrStr(Stringhaystack,Stringneedle){intn=haystack.length(),m=needle.length();if(m==0){return0;}int[]pi=newint[m];for(inti=1,j=0;i&l...
2021-11-24 12:34:35
214
原创 08自动机
列举出所有不同的输入,列举出所有不同的状态 如:得出表格下状态,右输入 ' ' +/- number otherstart start signed in_number endsigned end end in_number endin_number end end ...
2021-11-21 19:53:01
71
原创 08如何处理string转int越界
String 转int 两种方法,如果不可以使用long型if(res.charAt(0)=='+'){ for (int i = 1; i <res.length() ; i++) { digit=Character.getNumericValue(res.charAt(i)); if(value<=Integer.MAX_VALUE/10) value=value*10+digit; else{
2021-11-21 19:43:03
981
原创 07整数反转
publicintreverse(intx){intrev=0;while(x!=0){if(rev<Integer.MIN_VALUE/10||rev>Integer.MAX_VALUE/10){return0;}intdigit=x%10;x/=...
2021-11-20 12:06:36
188
原创 02只有next指针的链表操作
先创建一个节点,使用两个变量名(first,tail)命名该节点first=tail= new ListNode();此时first与tail完全相同,first.next等于tail.next。然后创建新的节点while(条件){{条件}temp= new ListNode()tail.next=temp;tail=tail.next;tail不断被重新赋值,first不变,返回first即可调查整个链表}...
2021-11-19 14:59:23
336
原创 01哈希表降低时间复杂度
public int[] twoSum(int[] nums, int target) { Map<Integer, Integer> map = new HashMap<Integer, Integer>(); for (int i = 0; i < nums.length; ++i) { if (map.containsKey(target - nums[i])) { return new int[]{map.get.
2021-11-19 14:31:17
403
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人