- 博客(27)
- 收藏
- 关注
原创 116. Populating Next Right Pointers in Each Node
You are given aperfect binary treewhereall leaves are on the same level, and every parent has two children. The binary tree has the following definition:struct Node { int val; Node *left; N...
2020-03-30 23:02:26 82
原创 114. Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example, given the following tree: 1 / \ 2 5/ \ \3 4 6The flattened tree should look like:1\ 2 \ 3...
2020-03-30 22:28:58 110
原创 Java 集合
学习廖雪峰的网站中java集合部分和其他资料中集合部分的学习记录。List1、在java9中添加了List新的初始化方法:List<> list = List.of();但是使用这种方法初始化的list是定长的,不能在使用add()函数添加元素,返回的list是只读的。2、遍历list的方法最高效的是使用Iterator。public class Main {...
2020-03-21 18:31:01 134
原创 113. Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.Note:A leaf is a node with no children.Example:Given the below binary tree andsum = 22,...
2020-03-20 17:18:08 103
原创 112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note:A leaf is a node with no children.Example:...
2020-03-20 17:10:07 63
原创 108. Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the...
2020-03-19 14:49:45 63
原创 106. Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, giveninorder =[9,3,15,20,7]postorder = [9...
2020-03-19 14:44:23 59
原创 105. Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, givenpreorder =[3,9,20,15,7]inorder = [9,3...
2020-03-06 16:54:25 104
原创 103. Binary Tree Zigzag Level Order Traversal
Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary tr...
2020-03-06 16:44:11 99
原创 98. Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keysless thanthe node's key. The ...
2020-03-06 16:36:30 63
原创 96. Unique Binary Search Trees
Givenn, how many structurally uniqueBST's(binary search trees) that store values 1 ...n?Example:Input: 3Output: 5Explanation:Given n = 3, there are a total of 5 unique BST's:1 3...
2020-03-03 21:45:00 69
原创 102. Binary Tree Level Order Traversal
Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree[3,9,20,null,null,15,7], 3 / \ 9 20...
2020-03-03 18:04:12 59
原创 101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree[1,2,2,3,4,4,3]is symmetric: 1 / \ 2 2/ \ / \3 4 4 3...
2020-03-03 17:54:48 59
原创 spring AOP学习笔记
Spring AOPAOP静态AOP=》直接对字节码进行更改,对切面做任何的更改都需要重新编译程序动态AOP=》在运行时织入,性能不如静态AOPSpring AOP包含AOP 内核一组框架服务AOP Alliance是由多个开源AOP共同制定的一组AOP标准接口AOP的流程:创建切面类创建ProxyFactory实例调用addAdvice(),为实例添加切面类使用...
2020-03-02 22:26:29 78
原创 Java语言基础
面向过程编程核心要素:数据结构: 原生类型、对象类型、数组类型、集合类型方法调用:访问性、返回类型、方法参数、异常等执行流程:赋值、逻辑、迭代、递归byte(8) char(16) short(16) int(32) long(64)java8public: allprotected: 继承+同包default: 同包private: 当前面向对象基础基本特性:封装...
2020-02-02 14:41:14 84
原创 快速排序
public class QuickSort { public static <T extends Comparable<T>> void quickSort(T[] arr, int n){ long startTime = System.currentTimeMillis(); __quickSort(arr, 0, n-1);...
2019-02-07 20:49:05 94
原创 归并排序优化
归并排序优化接上篇java实现归并排序 private static<T extends Comparable<T>> void __mergeSort(T arr[], int l, int r) { if(l>=r){ return; } int mid = (l+r)/2; ...
2019-01-21 22:37:00 225
原创 Java实现模板化归并排序
Java实现模板化归并排序import java.util.Comparator;public class MergeSort { public static <T extends Comparable<T>> void mergeSort(T arr[], int n){ long startTime = System.currentTim...
2019-01-21 22:34:18 365
原创 java泛型实现插入排序与选择排序
选择排序 //选择排序模板方法 //http://www.cnblogs.com/xiaomiganfan/p/5390252.html 泛型相关 public static&lt;T extends Comparable&lt;T&gt;&gt; void selectionSort(T[] arr, int n){ for(int i=0; i&lt;n; i...
2019-01-21 22:31:18 1361
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人