自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Coder进阶之路

谁终将声震人间,必长久深自缄默;谁终将点燃闪电,必长久如云漂泊。

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

转载 深入理解Java注解——注解处理器

如果没有用来读取注解的方法和工作,那么注解也就不会比注释更有用处了。使用注解的过程中,很重要的一部分就是创建于使用注解处理器。Java SE5扩展了反射机制的API,以帮助程序员快速的构造自定义注解处理器。注解处理器类库(java.lang.reflect.AnnotatedElement):  Java使用Annotation接口来代表程序元素前面的注解,该接口是所有Annotation类型的父接

2016-04-02 08:03:08 651

转载 深入理解Java注解——元注解及自定义注解

要深入学习注解,我们就必须能定义自己的注解,并使用注解,在定义自己的注解之前,我们就必须要了解Java为我们提供的元注解和相关定义注解的语法。元注解:  元注解的作用就是负责注解其他注解。Java5.0定义了4个标准的meta-annotation类型,它们被用来提供对其它 annotation类型作说明。Java5.0定义的元注解:     1.@Target,     2.@Retentio

2016-04-02 07:55:47 496

转载 深入理解Java注解——注解之基本概念

什么是注解(Annotation):  Annotation(注解)就是Java提供了一种元程序中的元素关联任何信息和着任何元数据(metadata)的途径和方法。Annotion(注解)是一个接口,程序可以通过反射来获取指定程序元素的Annotion对象,然后通过Annotion对象来获取注解里面的元数据。  Annotation(注解)是JDK5.0及以后版本引入的。它可以用于创建文档,跟踪代码

2016-04-02 07:47:00 3037

原创 Java反射机制的总结

能够分析类能力的程序成为反射,反射机制基本用途如下:在运行时分析类的能力。在运行中查看对象。实现通用的数组操作代码。利用Method对象。反射是一种功能强大且复杂的机制,使用它主要用来构造工具而不是进行应用程序的开发。得到Class对象的三种方法: 1.利用对象: Class c = new Object().getClass(); 2.利用Class的静态方法: Class c = C

2016-03-31 11:18:20 542

原创 LeetCode(33) Search in Rotated Sorted Array解题报告

Suppose a sorted array 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 found in the array return its index

2016-01-19 13:17:26 355

原创 LeetCode(80) Remove Duplicates from Sorted Array II

Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice?For example, Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first five elemen

2016-01-19 11:08:23 332

原创 LeetCode(26) Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with cons

2016-01-19 08:47:22 305

原创 LeetCode(236) Lowest Common Ancestor of a Binary Tree解题报告

Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes v and

2015-12-17 10:56:05 661

原创 LeetCode(254) Binary Tree Paths解题报告

Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]解题思路: 代码应该看得懂,先序遍历,处理字符串。public

2015-12-16 11:01:12 426

原创 LeetCode(235) Lowest Common Ancestor of a Binary Search Tree解题报告

Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two

2015-12-16 10:24:34 350

原创 LeetCode(222) Count Complete Tree Nodes解题报告

Given a complete binary tree, count the number of nodes.解题思路: 直接暴力求解超时,注意到一个完全二叉树,它的任何子树,要么是一个满二叉树,要么是一个完全二叉树。通过求一个二叉树最左的深度,最右的深度,来判断是不是满二叉树,如果不是满二叉树,则递归求解,如果是则套用公式(2 << 深度) - 1。public class Solution

2015-12-16 09:21:17 729

原创 LeetCode(199) Binary Tree Right Side View解题报告

Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example: Given the following binary tree, 1

2015-12-16 08:13:45 379

原创 LeetCode(173) Binary Search Tree Iterator解题报告

Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next() and hasN

2015-12-15 22:43:38 382

原创 LeetCode(145) Binary Tree Postorder Traversal解题报告

Given a binary tree, return the postorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].解题报告:递归解法是普通的后续遍历,不用多说,非递归用了一个栈来存储结点,想了好久也没

2015-12-15 19:02:50 745

原创 LeetCode(144) Binary Tree Preorder Traversal解题报告

Given a binary tree, return the preorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3解题思路:递归解法是很普通的先序遍历,非递归的解法灵感来源于我的解题报告LeetCode(114),看不懂的话可以去看

2015-12-15 17:09:51 413

原创 Tomcat(免安装版)环境变量及基本配置

Tomcat是什么就不用多说了,简单说一下java环境变量的配置问题,注意选择适合自己电脑版本的jdk,如果是32位系统千万别下载64位的jdk,而且tomcat也要选择合适版本的jdk,之前tomcat状态一直是stoped,很伤脑筋,试了各种解决办法,最后发现笔记本jdk是64位的,而tomcat为了能给云主机(32位)使用,下了32位的,所以服务打不开。一:JDK下载及配置jdk下载链接:h

2015-12-14 19:19:20 7514

原创 LeetCode(124) Binary Tree Maximum Path Sum解题报告

Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path

2015-12-14 11:50:46 419

原创 LeetCode(114) Flatten Binary Tree to Linked List解题报告

Given a binary tree, flatten it to a linked list in-place.For example, Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1 \ 2

2015-12-14 09:57:42 474

原创 LeetCode(111) Minimum Depth of Binary Tree解题报告

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.解题思路:递归求解,如果有比min还小的深度,就更新min,需要注意的是,最小深度是叶

2015-12-13 13:30:06 434

原创 LeetCode(110) Balanced Binary Tree解题报告

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by

2015-12-13 12:56:31 364

原创 LeetCode(109) 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.解题思路: 将节点转化为数组,然后递归求解public class Solution { public TreeNode sortedListToBST(ListNode h

2015-12-13 09:44:10 259

原创 LeetCode(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.解题思路: 取数组中点mid作为根节点,从start到mid-1作为左子树,mid+1到end作为右子树,递归调用即可。/** * Definition for a binary tree node.

2015-12-13 09:17:56 279

原创 LeetCode(107) 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}, 3

2015-12-13 08:52:18 286

原创 LeetCode(106) Construct Binary Tree from Inorder and Postorder Traversal解题报告

Given inorder and postorder traversal of a tree, construct the binary tree.解题思路:后序加中序构造树,会先序加中序就会后序加中序,不会的话看上一个题。。。。。。/** * Definition for a binary tree node. * public class TreeNode { * int val

2015-12-12 23:21:11 365

原创 LeetCode(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.解题思路: 先序遍历的第一个结点一定是根节点,查找根节点在中序遍历数组中的位置,前面的结点便是左子树,后面的便是右子树,然后递

2015-12-12 22:39:59 469

原创 LeetCode(97) Interleaving String解题报告

Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example, Given: s1 = “aabcc”, s2 = “dbbca”,When s3 = “aadbbcbcac”, return true. When s3 = “aadbbbaccc”, return false

2015-12-10 12:02:36 825

原创 LeetCode(103) Binary Tree Zigzag Level Order Traversal解题报告

Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between).For example: Given binary tree

2015-12-10 09:08:37 336

原创 LeetCode(102) Binary Tree Level Order Traversal解题报告

Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example: Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 1

2015-12-10 08:22:38 335

原创 LeetCode(99) Recover Binary Search Tree解题报告

Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note: A solution using O(n) space is pretty straight forward. Could you devise a const

2015-12-09 19:48:06 395

原创 LeetCode(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 is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the following is not:

2015-12-09 17:39:01 396

转载 【转】Java类成员变量默认初始化规则

一个变量作为类成员使用的时候,如果没有被初始化,java会为其分配默认值:Boolean falseChar '\u0000'(null)byte (byte)0short (short)0int 0long 0Lf

2015-12-08 17:04:36 1140

原创 LeetCode(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 keys less than the node’s key. The right

2015-12-08 12:16:22 579

原创 LeetCode(94) Binary Tree Inorder Traversal解题报告

Given a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2].Note: Recursive solution is trivial, could yo

2015-12-08 10:20:50 344

原创 LeetCode(95) Unique Binary Search Trees II解题报告

Given n, generate all structurally unique BST’s (binary search trees) that store values 1…n.For example, Given n = 3, your program should return all 5 unique BST’s shown below. 1 3 3

2015-12-07 21:42:21 602

原创 LeetCode(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 1 \ /

2015-12-07 20:13:34 523

原创 LeetCode(292) Nim Game解题报告

You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the

2015-12-05 19:51:18 627

转载 Google Java编程规范

Google Java编程风格指南 January 20, 2014 作者:Hawstein 出处:http://hawstein.com/posts/google-java-style.html 声明:本文采用以下协议进行授权: 自由转载-非商用-非衍生-保持署名|Creative Commons BY-NC-ND 3.0 ,转载请注明作者及出处。目录前言 源文件基础 源文件结构 格

2015-12-04 22:18:01 606

原创 LeetCode(303) Range Sum Query - Immutable解题报告

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example: Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRang

2015-12-04 13:11:35 795

原创 LeetCode(306) Addtive Number解题报告

Additive number is a string whose digits can form additive sequence. A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number in the se

2015-12-04 11:59:20 1046

空空如也

空空如也

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

TA关注的人

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