java
panzw2015
求知,心得体会
展开
-
96 Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2原创 2016-12-23 19:19:18 · 264 阅读 · 0 评论 -
新增函数式接口 java.util.function
函数式接口:只有一个抽象方法的接口 JDK8之前已有的函数式接口有:Runnable、Callable、 Comparator、 InvocationHandler、 PathMatcher 。。。等等 新定义的函数式接口:java.util.function中Predicate -- 传入一个参数,返回一个bool结果, 方法为boolean test(T t)Consumer -- 传入一个参...原创 2018-05-09 10:09:10 · 222 阅读 · 0 评论 -
最长公共子串 and 最长公共序列
最长公共子串和最长公共子序列。。。 举个栗子:str1="123ABCD456" str2 = "ABE12345D"最长公共子串是:123最长公共子序列是:12345 这两个都可以用动态规划,只是状态转移方程有点区别 最长公共子序列是:dp[i][j] -- 表示子串str1[0...i]和子串str[0...j]的最长公共子序列当str1[i]转载 2017-06-03 15:36:22 · 298 阅读 · 0 评论 -
堆排序
记录下堆排序。。。。堆排序的步骤:1)根据给定的数组建立堆结构,维护堆的性质;2)排序:每次将堆顶与最后一个元素(不算堆顶互换过来的)互换,再维护 第一个元素至最后一个元素 的堆性质,重新维护堆。。。依此循环import java.util.Arrays;public class HeapMakeTest { public static void main(Strin原创 2017-04-24 19:27:46 · 246 阅读 · 0 评论 -
2018届实习-阿里巴巴内推编程题
对于一个由一位十进制整数构成的二叉树,如果深度不超过4,可以用一个三位十进制整数构成的数组表示,具体规则如下:1、百位数表示树的层次L,12、数组里,L一定是单增的,也就是说后一个数的L大于等于前一个数的L;3、对于同一个L,P也是单增的,就是说在L不变的情况下,后一个数的P大于等于前一个数的P。例如:[ 113, 215, 221 ] 3 /原创 2017-03-14 21:45:24 · 5198 阅读 · 2 评论 -
剑指Offer : BST转为双向链表
输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表。要求不能创建任何新的结点,只能调整树中结点指针的指向。利用left作为双向链表的前驱指针,right作为双向链表的后驱指针,采用递归从子树开始转换。package convertBSTtoDoubleLink;class TreeNode { int val = 0; TreeNode lef原创 2017-03-28 21:52:00 · 1163 阅读 · 0 评论 -
各种常用排序的时间复杂度和稳定性以及代码实现
看到这位博主的,感觉很有用,转载记录下,声明转载地址:http://blog.csdn.net/hr10707020217/article/details/10581371怎么记忆稳定性:总过四大类排序:插入、选择、交换、归并(基数排序暂且不算)比较高级一点的(时间复杂度低一点得)shell排序,堆排序,快速排序(除了归并排序)都是不稳定的,在加上低一级的选择排序是不稳转载 2017-04-07 10:01:14 · 397 阅读 · 0 评论 -
Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路:找到中间节点,中间节点是BST树根,然后中间节点的 左半部分 是树根的左子树, 右半部分是树根的右子树,依次递归下去。/** * Definition for原创 2017-01-12 20:21:21 · 321 阅读 · 0 评论 -
Find Minimum in Rotated Sorted Array II
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.The array may cont原创 2017-01-12 19:22:12 · 210 阅读 · 0 评论 -
Search in Rotated Sorted Array
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If foun原创 2017-01-10 20:55:40 · 298 阅读 · 0 评论 -
Search in Rotated Sorted Array II
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Write a function to determine if a given target原创 2017-01-10 20:44:14 · 649 阅读 · 0 评论 -
java8 stream
Java 8 中的 Stream 是对集合(Collection)对象功能的增强,它专注于对集合对象进行各种非常便利、高效的聚合操作(aggregate operation),或者大批量数据操作 (bulk dataoperation)。Stream API 借助于同样新出现的Lambda 表达式,极大的提高编程效率和程序可读性。同时它提供串行和并行两种模式进行汇聚操作,并发模式能够充分利用多核处...原创 2018-05-04 18:32:37 · 175 阅读 · 0 评论