
剑指offer
文章平均质量分 56
尽拣寒枝不肯栖
这个作者很懒,什么都没留下…
展开
-
剑指offer找链表的公共节点
public class findcommonnode{public static void main(String[] args) {ListNode p1 = new ListNode(1);ListNode p2 = new ListNode(1);ListNode p3 = new ListNode(1);ListNode pq4 = new ListNode(原创 2016-09-16 14:11:24 · 250 阅读 · 0 评论 -
求二叉树深度
package sword;public class tmp1 { public static void main(String[] args) { System.out.println(19 & 20); } int count = 1; int max = 0; public int TreeDepth(TreeNode pRoot) { if(pRoot==nul原创 2016-09-16 14:30:36 · 296 阅读 · 0 评论 -
判断给定数组是不是二叉搜索树的后序遍历
public class tmp1 { public static void main(String[] args) { int[] a = { 1, 3, 2, 5, 6, 4 }; System.out.println(VerifySquenceOfBST(a)); } public static boolean VerifySquenceOfBST(int[] sequen原创 2016-09-16 15:49:16 · 294 阅读 · 0 评论 -
二叉树打印
import java.util.ArrayList;public class tmp1 {public static void main(String[] args) {TreeNode p1 =null;}public static int count = 0;public static ArrayList> row = new ArrayLis原创 2016-09-16 18:51:34 · 222 阅读 · 0 评论 -
连续子数组最大和
public class tmp { public static void main(String[] args) { int[] a = { 6, -3, -2, 7, -15, 1, 2, 2 }; System.out.println(FindGreatestSumOfSubArray(a)); } public static int FindGreatestSumOfSub原创 2016-09-16 19:18:39 · 201 阅读 · 0 评论 -
二叉树镜像对称
public class tmp { public static void main(String[] args) { TreeNode p1 = new TreeNode(8); TreeNode p2 = new TreeNode(6); TreeNode p3 = new TreeNode(9); TreeNode p4= new TreeNode(5); TreeNo原创 2016-09-16 23:09:23 · 373 阅读 · 0 评论 -
由先序中序求二叉树
我写的有个地方没想到,就是在中序求出左子树的节点后,又从先序求左子树的节点个数,其实两个是一样的。。。。复杂程序package sword;import java.util.LinkedList;import java.util.Queue;public class tmp { public static void main(String[] args) { int[]原创 2016-09-17 16:48:20 · 362 阅读 · 0 评论