- 博客(14)
- 资源 (2)
- 收藏
- 关注
原创 (有序数组中移除重复元素)Remove Duplicates from Sorted Array
题目: Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice? For example, Given sorted array A =[1,1,1,2,2,3], Your function should return length =5, and A is now[
2017-05-31 23:21:38 426
原创 合并有序数组
题目: Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assume that A has enough space to hold additional elements from B. The number of elements init
2017-05-31 21:35:37 265
原创 升序数组转成二叉排序树
题目 Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 分析将二叉查找树进行中序遍历,就可以得到一个升序排序的数组,因此,一个已经排序的数组可以看做一个中序遍历得到的数组,要得到一个高度平衡的二叉查找树,可以使得左右子树的节点数尽可能相等。因此,可以采
2017-05-31 00:10:36 2097
原创 买卖股票 I II III
Best Time to Buy and Sell Stock IDescription: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie,
2017-05-30 23:05:46 438
原创 数组中最长的连续序列(longest consecutive sequence)
题目:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given[100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is[1, 2, 3, 4].
2017-05-30 20:37:55 941
原创 二叉树的最小深度
题目 Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. java实现public int run(TreeNode root) {
2017-05-25 22:52:11 322
原创 JVM学习笔记(二)jvm类加载机制
类加载过程 虚拟机把描述类的数据从Class文件加载到内存,并对数据进行校验、转换解析和初始化,最终形成可以被虚拟机直接使用的java类型,这就是虚拟机的类加载机制。 类从被加载到虚拟机内存中开始,到卸载出内存为止,它的生命周期包括了:加载(Loading)、验证(Verification)、准备(Preparation)、解析(Resolution)、初始化(Initialization)
2017-05-25 22:44:10 299
原创 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 1 \
2017-05-17 16:21:12 206
原创 01背包问题
题目有N件物品和一个容量为V的背包。第i件物品的费用是c[i],价值是w[i]。求解将哪些物品装入背包可使价值总和最大。基本思路这是最基础的背包问题,特点是:每种物品仅有一件,可以选择放或不放。 用子问题定义状态:即f[i][v]表示前i件物品恰放入一个容量为v的背包可以获得的最大价值。则其状态转移方程便是: f[i][v]=max{f[i-1][v],f[i-1][v-c[i]]+w[i]}这
2017-05-15 16:41:53 456
原创 JVM学习笔记(一)运行时数据区
运行时数据区 java虚拟机在执行java程序的过程中会把所管理的内存划分为若干个不同的数据区域。这些区域都有各自的用途,以及创建和销毁的时间。 有的区域随着虚拟机进程的启动而存在,随虚拟机进程的退出而销毁; 有的区域则依赖用户线程的启动和结束而建立和销毁。 java虚拟机所管理的内存将会包括以下几个运行时数据区域程序计数器 程序计数器(Program Counter Register)
2017-05-11 22:54:13 435
原创 binary-tree-level-order-traversal-ii
题目Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example: Given binary tree{3,9,20,#,#,15,7},
2017-05-08 22:01:09 241
原创 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. For example: Given the below binary tree andsum = 22, 5 / \
2017-05-08 21:00:57 318
原创 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. For example: Given the below binary tre
2017-05-02 21:31:21 276
原创 深入浅出Spring(三) 五种通知
通知简介 前置通知(Before advice)在目标方式执行之前执行,所以获取不到目标方法执行后的返回值后置通知(After returning advice)后置通知可以获取到目标方法的返回值 当目标方法抛出异常,后置通知将不再执行 异常通知(After throwing advice)目标方法发生 异常时执行最终通知(finally advice)无论目标方法是否抛出异常都将执行环绕通知(Ar
2017-05-01 16:06:00 484
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人