自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

肖胖孩de部落格

码农转行写报告了

  • 博客(24)
  • 收藏
  • 关注

原创 Java | LeetCode | 61. Rotate List

LeetCode | 61. Rotate List题目描述Given a linked list, rotate the list to the right by k places, where k is non-negative.Example 1:Input: 1->2->3->4->5->NULL, k = 2Output: 4->5->...

2019-04-18 20:39:21 126

原创 Java | LeetCode | 25. Reverse Nodes in k-Group

LeetCode | 25. Reverse Nodes in k-Group题目描述Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the ...

2019-04-18 17:15:34 105

原创 Java | LeetCode | 21. Merge Two Sorted Lists

LeetCode | 21. Merge Two Sorted Lists题目描述Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input:...

2019-04-18 16:17:54 133

原创 Java | LeetCode | 19. Remove Nth Node From End of List

LeetCode | 19. Remove Nth Node From End of List题目描述Given a linked list, remove the n-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n = ...

2019-04-17 23:49:18 117

原创 Java | 剑指Offer | 最小的K个数

剑指Offer | 最小的K个数题目描述输入n个整数,找出其中最小的K个数。例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,。思路排序,输出前k个可以用到的排序有:快排、堆排序代码1. 快排import java.util.ArrayList;public class Solution { public ArrayList<Int...

2019-04-16 16:52:19 88

原创 Java | 剑指Offer | 斐波那契数列 | 跳台阶 | 变态跳台阶 | 矩阵覆盖

剑指Offer | 斐波那契数列题目描述大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0)。n<=39思路f(n) = f(n-1) + f(n-2)可以用递归,也可以用动态规划代码1. 动态规划public class Solution { public int Fibonacci(int n) { ...

2019-04-12 12:26:57 212

原创 Java | 剑指Offer | 旋转数组的最小数字

剑指Offer | 旋转数组的最小数字题目描述把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个非减排序的数组的一个旋转,输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。思路本题的目的是要找到旋转的点。因为旋转点前后的子数组都分别是非减的,...

2019-04-12 12:03:53 100

原创 Java | 剑指Offer | 用两个栈实现对列

剑指Offer | 用两个栈实现对列题目描述用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。思路输入:[“PSH1”,“PSH2”,“PSH3”,“POP”,“POP”,“PSH4”,“POP”,“PSH5”,“POP”,“POP”]输出:1,2,3,4,5用stack1存放push的所有值,如果需要出列,首先判断stack2里面有没有值,如果没...

2019-04-12 11:42:45 96

原创 Java | 剑指Offer | 重建二叉树 | 已知前序和中序复原树

剑指Offer | 重建二叉树 | 已知前序和中序复原树题目描述输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。思路和LeetCode这道题一样Java | LeetCode | 105. Constr...

2019-04-12 11:20:05 186

原创 Java | 剑指Offer | 从尾到头打印链表

剑指Offer | 从尾到头打印链表题目描述输入一个链表,按链表值从尾到头的顺序返回一个ArrayList。思路递归:遍历链表,每次将val插入到list的第一个非递归1:利用栈先入后出的思想,把链表推入栈,然后出栈非递归2:参考反转链表,将链表反转之后依次输出代码1. 递归import java.util.ArrayList;public class Solution { ...

2019-04-12 11:16:53 78

原创 Java | 剑指Offer | 替换空格

剑指Offer | 替换空格题目描述请实现一个函数,将一个字符串中的每个空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。思路用一个StringBuffer存放结果,将字符串从前往后遍历,是空格就append("%20"),其他就append(str.charAt(i)+"")。代码public class Sol...

2019-04-12 10:54:33 75

原创 Java | 剑指Offer | 二维数组中的查找

剑指Offer | 二维数组中的查找题目描述在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。思路每行从左到右递增,每列从上到下递增,那么最大值一定在最后一行的最后一个数。最左下角或右上角的数,只有两种移动方法,且两侧单调性不一样:对于左下角而言...

2019-04-12 10:39:31 63

原创 Java | LeetCode | 494. Target Sum | 背包问题 | 动态规划

494. Target Sum | 背包问题 | 动态规划问题描述You are given a list of non-negative integers, a1, a2, …, an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - a...

2019-04-10 17:19:08 524

原创 Java | LeetCode | 416. Partition Equal Subset Sum | 背包问题 | 动态规划

416. Partition Equal Subset Sum | 背包问题问题描述Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subse...

2019-04-10 16:41:28 478

原创 Java | LeetCode | 106. Construct Binary Tree from Inorder and Postorder Traversal | 已知中序和后序复原树

106. Construct Binary Tree from Inorder and Postorder Traversal | 已知中序和后序复原树class Solution { public TreeNode buildTree(int[] in, int[] post) { if(in.length==0 || post.length==0 || in.length!=post....

2019-04-01 14:41:56 208

原创 Java | LeetCode | 105. Construct Binary Tree from Preorder and Inorder Traversal | 已知前序和中序复原树

105. Construct Binary Tree from Preorder and Inorder Traversal | 已知前序和中序复原树/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode r...

2019-04-01 14:37:08 114

原创 Java | LeetCode | 230. Kth Smallest Element in a BST | 第k个最小值

230. Kth Smallest Element in a BST | 第k个最小值/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { v...

2019-04-01 14:21:32 99

原创 Java | LeetCode | 103. Binary Tree Zigzag Level Order Traversal | 之字形遍历

103. Binary Tree Zigzag Level Order Traversal | 之字形遍历/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(...

2019-04-01 14:18:51 106

原创 Java | LeetCode | 107. Binary Tree Level Order Traversal II | 层序遍历

107. Binary Tree Level Order Traversal II | 层序遍历/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x...

2019-04-01 14:14:42 76

原创 Java | LeetCode | 102. Binary Tree Level Order Traversal | 层序遍历

102. Binary Tree Level Order Traversal | 层序遍历/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) {...

2019-04-01 14:11:27 86

原创 Java | LeetCode | 145. Binary Tree Postorder Traversal | 后序遍历

145. Binary Tree Postorder Traversal | 后序遍历/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { v...

2019-04-01 14:09:28 80

原创 Java | LeetCode | 144. Binary Tree Preorder Traversal | 前序遍历

144. Binary Tree Preorder Traversal | 前序遍历/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { va...

2019-04-01 14:07:37 117

原创 Java | LeetCode | 94. Binary Tree Inorder Traversal | 中序遍历

94. Binary Tree Inorder Traversal | 前序遍历/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val ...

2019-04-01 14:04:26 58

原创 Java | 设计模式 | 单例模式(Singleton)

单例模式单例模式,是一种常用的软件设计模式。在它的核心结构中只包含一个被称为单例的特殊类。通过单例模式可以保证系统中,应用该模式的一个类只有一个实例。即一个类只有一个对象实例。Java中单例模式定义:“一个类有且仅有一个实例,并且自行实例化向整个系统提供。”基本实现思路单例模式要求类能够有返回对象一个引用(永远是同一个)和一个获得该实例的方法(必须是静态方法,通常使用getInstance...

2019-03-31 23:04:11 100

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除