java
文章平均质量分 83
seucxt
这个作者很懒,什么都没留下…
展开
-
【Java】java嵌套类及内部类
一、什么是嵌套类及内部类 可以在一个类的内部定义一个类,这种类称为嵌套类(nested classes),它有两种类型:静态嵌套类和非静态嵌套类。静态嵌套类很少用,最重要的是非静态嵌套类,被称作内部类(inner)。其中inner类被分为三种:(1)在一个类(外部类)中直接定义的内部类;(2)在一个方法(外部类的方法)中定义的内部类;(3)匿名内部类;二、静态嵌套类原创 2016-12-14 20:12:42 · 294 阅读 · 0 评论 -
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.本题采用递归的方式来进行:/** * Definition for a binary tree node. *原创 2017-06-10 17:01:20 · 185 阅读 · 0 评论 -
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 tr原创 2017-06-10 16:33:03 · 147 阅读 · 0 评论 -
Combinations
Given two integers n and k, return all possible combinations ofk numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]原创 2017-06-10 15:53:44 · 170 阅读 · 0 评论 -
Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A straight forward solution using O(mn) s原创 2017-06-10 15:42:02 · 123 阅读 · 0 评论 -
Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy the follo原创 2017-06-10 15:05:43 · 116 阅读 · 0 评论 -
Search a 2D Matrix
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each原创 2017-06-10 14:34:26 · 113 阅读 · 0 评论 -
全排列问题 java
经常会遇到字符串全排列的问题。例如:输入为{‘a’,’b’,’c’},则其全排列组合为abc,acb,bac,bca,cba,cab。对于输入长度为n的字符串数组,全排列组合为n!种。思路:从字符串数组中每次选取一个元素,作为结果中的第一个元素。然后,对剩余的元素全排列,步骤跟上面一样。很明显这是个递归处理的过程,一直到最后即可。public class Main { publi原创 2017-06-10 14:09:49 · 212 阅读 · 0 评论 -
Java Annotation注解
JPA简介:JPA全称Java Persistence API。JPA通过JDK5.0注解或XML描述对象——关系表的映射关系,并将运行期的实体对象持久化到数据库中。JPA的总体思想和现有Hibernate、TopLink、JDP等ORM框架大体一致。总的来说,JPA包括以下3方面的技术:(1)ORM映射元数据JPA支持XML和JDK5.0注解两种元数据的形式,元数据描述对象和原创 2017-03-27 21:56:04 · 301 阅读 · 0 评论 -
【Java】Java中,String、StringBuffer和StringBuilder的区别
1、StringString:字符串常量,字符串长度不可变。Java中的String是immutable(不可变)的。String类的包含如下定义: /** The value is used for character storage. */ private final char value[]; /** The offset is the原创 2016-12-17 20:52:10 · 170 阅读 · 0 评论 -
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./** * Definition for a binary tree node. * public class原创 2017-06-10 17:11:22 · 196 阅读 · 0 评论