![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
剑指offer
springTen
这个作者很懒,什么都没留下…
展开
-
剑指offer 28 判断二叉树是否对称 Java
如题:public class BinaryTreeIsSymmertrical28 { static class Node { int val; Node left; Node right; public Node(int val){ this.val = val; } ...原创 2019-08-12 18:57:31 · 70 阅读 · 0 评论 -
剑指offer21 奇偶序列 Java
public class OddEvenSequence21 { public static void main(String[] args) { int[] arr = {1, 2, 5, 6, 4, 3, 8, 0}; adjust(arr); for (int i = 0; i < arr.length; i++) { ...原创 2019-08-15 09:34:25 · 134 阅读 · 0 评论 -
剑指offer 56 出现一次的数 Java
数组中只有一个数只出现1次,其他的出现3次,找出这个数public class OnceInOtherThree56 { public static void main(String[] args) { int[] arr = {1, 2, 3, 4, 1, 1, 2, 4, 4, 2}; findThat(arr); } priv...原创 2019-08-15 09:34:20 · 87 阅读 · 0 评论 -
剑指offer32 从上到下打印二叉树 Java
public class PrintBinaryTreeTopToBottom32 { static class Node { int val; Node left; Node right; public Node(int val){ this.val = val; } ...原创 2019-08-15 09:34:14 · 71 阅读 · 0 评论 -
剑指offer 06 倒序打印链表 Java
public class PrintListFromTailToHead06 { static class Node { int val; Node next; public Node(int val){ this.val = val; } } public static void m...原创 2019-08-15 09:34:08 · 75 阅读 · 0 评论 -
剑指offer29 顺时针打印矩阵序列 Java
public class PrintMatrixSequence29 { public static void main(String[] args) { int[][] matrix = {{1, 2, 3, 4}, {5, 6, 7, 8},{9, 10, 11, 12}, {13, 14, 15, 16}}; int rows = matrix.le...原创 2019-08-15 09:33:53 · 77 阅读 · 0 评论 -
剑指offer 07 重建二叉树 Java
public class RebuildBinaryTree07_ { static class Node { int val; Node left; Node right; public Node(int val){ this.val = val; } @Overr...原创 2019-08-15 09:33:46 · 103 阅读 · 0 评论 -
剑指offer24 反转链表 Java
public class ReverseLinkList24 { static class Node { int val; Node next; public Node(int val){ this.val = val; } @Override public Strin...原创 2019-08-15 09:33:39 · 84 阅读 · 0 评论 -
剑指offer58 反转字符串 Java
public class ReverseString58_ { public static void main(String[] args) { String str = "i am a student!"; System.out.println(reverseString(str)); } private static St...原创 2019-08-15 09:33:33 · 99 阅读 · 0 评论 -
剑指offer30 包含min函数的栈 Java
public class StackIncludeMinFunc30_ { static class Stackck { static Stack<Integer> stack = new Stack<>(); static Stack<Integer> minStack = new Stack<>()...原创 2019-08-14 08:59:36 · 68 阅读 · 0 评论 -
剑指offer31 验证一个出栈顺序是否正确 Java
public class StackIsValide31 { public static void main(String[] args) { int[] in = {1, 2, 3, 4, 5}; int[] out = {4, 5, 3, 1, 1}; System.out.println(isValide(in, out)); ...原创 2019-08-14 08:59:23 · 176 阅读 · 0 评论 -
剑指offer26 树的子结构 Java
public class SubTreeConstruct26_ { static class Node { int val; Node left; Node right; public Node(int val){ this.val = val; } @Overrid...原创 2019-08-14 08:59:13 · 98 阅读 · 0 评论 -
剑指offer57 和为某数的两个数字 Java
public class SumEqualsNum57 { public static void main(String[] args) { int[] arr = {1, 2, 3, 5, 6, 7, 8, 9, 10}; findTwo(arr, 14); } private static void findTwo(int[] arr...原创 2019-08-14 08:59:07 · 91 阅读 · 0 评论 -
剑指offer57 和为某数的连续子数组 Java
public class SumOfSerialNumber57_ { public static void main(String[] args) { find(15); } private static void find(int sum) { if (sum <= 2) return; i...原创 2019-08-14 08:59:01 · 213 阅读 · 0 评论 -
剑指offer52 两个链表的第一个公共节点 Java
public class TwoLinkPublicNode52 { static class Node { int val; Node next; public Node(int val){ this.val = val; } @Override public Str...原创 2019-08-14 08:58:53 · 117 阅读 · 0 评论 -
剑指offer56 数组里只出现一次的两个数字 Java
public class TwoNumShowOnceInArr56 { public static void main(String[] args) { int[] arr = {2, 4, 3, 6, 3, 2, 5, 5}; findit(arr); } private static void findit(int[] arr) {...原创 2019-08-14 08:58:46 · 86 阅读 · 0 评论 -
剑指offer09 两个队列实现一个栈 Java
public class TwoQueueForOneStack09 { static class Stackck { static Queue<Integer> queue1 = new LinkedList<>(); static Queue<Integer> queue2 = new LinkedList<&...原创 2019-08-14 08:58:39 · 58 阅读 · 0 评论 -
剑指offer09 两个栈实现一个队列 Java
public class TwoStackForOneQueue09 { static class Queueue{ static Stack<Integer> stack1 = new Stack<>(); static Stack<Integer> stack2 = new Stack<>(); ...原创 2019-08-14 08:58:13 · 70 阅读 · 0 评论 -
剑指offer39 出现次数超过一半的数 Java
public class NumOverHalf39 { public static void main(String[] args) { int[] arr = {1, 2, 3, 2, 2, 2, 5, 4, 2}; System.out.println(overhaf(arr)); } private static int over...原创 2019-08-15 09:34:31 · 74 阅读 · 0 评论 -
剑指offer15 二进制中1的个数 Java
public class NumOfOne15 { public static void main(String[] args) { int n = 15; System.out.println(countOne2(n)); } private static int countOne(int n) { int count ...原创 2019-08-15 09:34:37 · 69 阅读 · 0 评论 -
剑指offer21 链表中的倒数第K个节点 Java
public class NumKOfReverse21 { static class Node { int val; Node next; public Node(int val){ this.val = val; } @Override public String ...原创 2019-08-17 15:11:53 · 79 阅读 · 0 评论 -
剑指offer54 二叉搜索树的第K大节点 Java
public class BinaryTreeK54 { static class Node { int val; Node left; Node right; public Node(int val) { this.val = val; } @Override ...原创 2019-08-12 19:00:13 · 88 阅读 · 0 评论 -
剑指offer27 二叉树的镜像 Java
public class BinaryTreeMirror27_ { static class Node { int val; Node left; Node right; public Node(int val){ this.val = val; } @Overrid...原创 2019-08-19 09:00:28 · 77 阅读 · 0 评论 -
剑指offer 剪绳子 java
题目:给你一根长度为n的绳子,请把绳子剪成m段 (m和n都是整数,n>1并且m>1)每段绳子的长度记为k[0],k[1],…,k[m].请问k[0]k[1]…*k[m]可能的最大乘积是多少?例如,当绳子的长度为8时,我们把它剪成长度分别为2,3,3的三段,此时得到的最大乘积是18.相信很多人对products数组的值有些疑问。1、我的理解是这样的,如果你的length在0-3这个范...原创 2019-04-01 19:18:40 · 165 阅读 · 0 评论 -
剑指offer 34 二叉树中和为某一值的路径 Java
public class BinaryTreePath34_ { static class Node { int val; Node left; Node right; public Node(int val) { this.val = val; } @Overri...原创 2019-08-19 09:00:40 · 86 阅读 · 0 评论 -
剑指offer 36 二叉搜索树转化为双向链表 Java
public class BinaryTreeToDoubleLinkList36 { static class Node { int val; Node left; Node right; public Node(int val) { this.val = val; } ...原创 2019-08-19 09:00:33 · 106 阅读 · 0 评论 -
剑指offer42 连续子数组最大和 Java
public class ContinueSubArrayMaxSum42__ { public static void main(String[] args) { int[] arr = {1, -2, 4, 10, -4, 7, 2, -5}; System.out.println(subArrayMaxSum(arr)); } pr...原创 2019-08-19 09:01:27 · 105 阅读 · 1 评论 -
剑指offer55 二叉树高度||深度 Java
public class DeepOfBinaryTree55 { static class Node { int val; Node left; Node right; public Node(int val) { this.val = val; } @Overr...原创 2019-08-19 09:00:21 · 111 阅读 · 0 评论 -
剑指offer 18 删除链表中重复节点 Java
public class DeleteRepeatNode18 { static class Node{ int data; Node next; public Node(int data) { this.data = data; } } public static void mai...原创 2019-08-17 15:12:44 · 95 阅读 · 0 评论 -
剑指offer12 矩阵中的路径 Java
public class FindPath12_ { public static void main(String[] args) { char[][] arr = {{'a', 'b', 't', 'g'}, {'c', 'f', 'c', 's'}, {'j', 'd', ...原创 2019-08-19 09:00:15 · 98 阅读 · 0 评论 -
剑指offer53 有序数组查找数字出现的次数 Java
public class FineNumber53 { public static void main(String[] args) { int[] arr = {1, 2, 3, 3, 3, 4, 5}; int n = 3; int first = times(arr, n); int last = times(arr,...原创 2019-08-17 15:12:39 · 160 阅读 · 1 评论 -
剑指offer49 丑数
丑数,2,3,5的倍数,1是第一个丑数public class GetUglyNumber49 { public static void main(String[] args) { int n = 55; System.out.println(ugly(n)); } private static int ugly(int n) {...原创 2019-08-17 15:12:34 · 111 阅读 · 0 评论 -
剑指offer55 是否是平衡二叉树 Java
public class IsBalancedTree55 { static class Node { int val; Node left; Node right; public Node(int val) { this.val = val; } @Overrid...原创 2019-08-17 15:12:28 · 119 阅读 · 0 评论 -
剑指offer58 左旋转字符串 Java
public class LeftReverseString58 { public static void main(String[] args) { String str = "abcdefg"; System.out.println(leftReverse(str, 3)); } private static String leftR...原创 2019-08-17 15:12:22 · 83 阅读 · 0 评论 -
剑指offer48 最长不重复子串 Java
public class LongestSubStringWithoutDuplication48__ { public static void main(String[] args) { String str = "arabcacfr"; System.out.println(subString(str)); int i = 0; ...原创 2019-08-17 15:12:17 · 130 阅读 · 0 评论 -
剑指offer25 合并两个有序链表 Java
public class MergeSortedLinkList25 { static class Node { int val; Node next; public Node(int val){ this.val = val; } @Override public S...原创 2019-08-17 15:12:12 · 82 阅读 · 0 评论 -
剑指offer40 最小的K个数 Java
public class MinestK40_ { public static void main(String[] args) { int[] arr = {4, 5, 1, 6, 2, 7, 3, 8}; int k = 4; minestK(arr, k - 1); for (int i = 0; i < 4; ...原创 2019-08-17 15:12:05 · 90 阅读 · 0 评论 -
剑指offer08 二叉搜索树中序遍历某节点的下一个节点 Java
private static Node nextNode(Node node) { //只有一个节点 if (node.left == null && node.right == null) return null; //若该节点有右孩子 if (node.right != null) { ...原创 2019-08-17 15:11:59 · 253 阅读 · 0 评论 -
剑指offer33 判断指定序列是否是二叉搜索树的后序遍历 Java
public class VerifySequenOfBST33_ { public static void main(String[] args) { int[] arr = {5, 7, 6, 9, 11, 10, 8}; System.out.println(check(arr, 0, arr.length - 1)); } pr...原创 2019-08-14 08:58:06 · 84 阅读 · 0 评论