
LeetCode
Haha@25
300字以内
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
160. Intersection of Two Linked Lists
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */public...原创 2020-01-16 16:19:53 · 158 阅读 · 0 评论 -
回溯算法
子集原创 2020-01-01 22:34:29 · 96 阅读 · 0 评论 -
102. 二叉树的层次遍历
错误的算法:/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution { ...原创 2020-01-01 20:49:53 · 111 阅读 · 0 评论 -
145. 二叉树的后序遍历
后序遍历递归方法:/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution...原创 2020-01-01 17:31:52 · 90 阅读 · 0 评论 -
94. 二叉树的中序遍历
中序递归&&非递归递归方法:/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */c...原创 2020-01-01 17:25:43 · 103 阅读 · 0 评论 -
144. 二叉树的前序遍历
递归方法:/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution {...原创 2020-01-01 12:48:34 · 74 阅读 · 0 评论 -
7. 整数反转
整数反转通过不断地执行 remainder=x%10; x/=10; sum = sum*10+remainder; 来实现整数低位弹出,并不断向高位移动;需要注意的点:1,判断是否溢出(溢出前进行检查)int类型的范围 [-2,147,483,648,2,147,483,647]对正数,当前一次的sum满足sum > Integer.MAX_VALUE/10 (...原创 2020-01-01 11:29:28 · 124 阅读 · 0 评论 -
28. 实现 strStr(),字符串模式匹配问题
实现 String的 indexof()函数;方法一:普通模式匹配class Solution { public int strStr(String haystack, String needle) { int i,j,tmpI,m=haystack.length()-needle.length(); for(i =0;i<=m;i++...原创 2019-12-31 23:30:55 · 156 阅读 · 0 评论 -
26. 删除排序数组中的重复项
class Solution { public int removeDuplicates(int[] nums) { if(nums.length==0)//对空数组要特殊处理 return 0; int i=1,j=1; int currentNum= nums[0]; while(j<nums...原创 2019-12-31 21:24:55 · 81 阅读 · 0 评论 -
27. Remove Element
我的解法:class Solution { public int removeElement(int[] nums, int val) { int deleteNums=0;//记录非选中值要向前移动的次数 for(int i =0;i<nums.length;i++) { if(nums[i]==...原创 2019-12-31 17:57:26 · 106 阅读 · 0 评论