自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Lnho的专栏

发表是最好的记忆

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

原创 Leet Code OJ 112. Path Sum [Difficulty: Easy]

题目: 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 tree and su

2016-02-29 19:19:14 889

原创 Leet Code OJ 101. Symmetric Tree [Difficulty: Easy]

题目: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: But the following is not: Note: Bonus points if you

2016-02-29 17:21:39 869

原创 Leet Code OJ 202. Happy Number [Difficulty: Easy]

题目: Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares

2016-02-27 18:02:05 733

原创 Leet Code OJ 70. Climbing Stairs [Difficulty: Easy]

题目: You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?翻译: 你在爬一个楼梯。到达顶部有n级阶梯。 每次你可以选择

2016-02-27 17:49:25 2995

原创 Leet Code OJ 100. Same Tree [Difficulty: Easy]

题目: Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.翻译: 给2个二叉树,写一

2016-02-27 17:39:05 949

原创 Leet Code OJ 263. Ugly Number [Difficulty: Easy]

题目: Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since

2016-02-27 17:33:29 1021

原创 Leet Code OJ 169. Majority Element [Difficulty: Easy]

题目: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element al

2016-02-26 18:36:19 1706

原创 Leet Code OJ 217. Contains Duplicate [Difficulty: Easy]

题目: Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every elemen

2016-02-26 18:16:24 1895

原创 Leet Code OJ 283. Move Zeroes [Difficulty: Easy]

题目: Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your

2016-02-26 14:36:32 1235

原创 Leet Code OJ 226. Invert Binary Tree [Difficulty: Easy]

题目: Invert a binary tree.4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1代码实现:/** * Definition for a binary tree node. * public class TreeNod

2016-02-26 14:16:12 905

原创 Leet Code OJ 104. Maximum Depth of Binary Tree [Difficulty: Easy]

题目: Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.代码实现:/** * Definition for a binary tr

2016-02-26 14:13:39 1683 2

原创 Leet Code OJ 258. Add Digits [Difficulty: Easy]

题目: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one dig

2016-02-26 14:09:24 1593 1

原创 Leet Code OJ 231. Power of Two [Difficulty: Easy]

题目: Given an integer, write a function to determine if it is a power of two.分析: 题意是给定一个整数,判断它是不是2的n次方。代码实现:public class Solution { public boolean isPowerOfTwo(int n) { if(n<1){

2016-02-26 13:49:20 731

原创 Leet Code OJ 242. Valid Anagram [Difficulty: Easy]

题目: Given two strings s and t, write a function to determine if t is an anagram of s.For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t = “car”, return false.Note: You may assume

2016-02-26 12:58:24 1364 2

原创 Leet Code OJ 292. Nim Game [Difficulty: Easy]

题目: 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

2016-02-26 12:28:17 962

原创 Leet Code OJ 136. Single Number [Difficulty: Medium]

题目: Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using ext

2016-02-26 11:56:53 696

原创 Hibernate中使用未映射为主键的“id”字段进行查询的场景分析

今天遇到一个hibernate的问题,有一个实体的主键字段叫userId,数据库里的字段名称是user_id。 然后在某个查询语句里有这样一段代码:Criterion criterion = Restrictions.eq("id",userId);User user=userDao.findUnique(criterion);当时看到这段代码的感觉是应该会报错吧,因为这个实体并没有id这个字段

2016-02-18 14:48:58 1771

原创 浅谈最小生成树的算法思路(二)Kruskal算法

Kruskal算法是另外一种最小生成树的常见算法,理解起来,笔者觉得是比Prim算法要简单的。算法思路定义2个集合,集合P代表已经确定的边的集合,初始为空集。集合Q代表还未确定的边的集合,初始化为所有的边的集合。从所有图的所有边中选取一条最短的边

2016-02-16 22:46:17 1331

原创 浅谈最小生成树的算法思路(一)Prim算法

Prim算法是求最小生成树的一种常见算法,简单谈一下笔者自己的理解。算法思路设已经确定的点集为P,初始为空。设还未确定的点集为Q,初始为该图所有点的集合。设已经确定的边为X,初始为空。选取任意一点作为起始点,将该点添加到集合P中,并从Q中移除该点。从P中找到一个点A,从Q中找到一个点B,使得2点之间的路径AB的权值最小。将路径AB添加到X,将Q中的点B添加到集合P中,并从Q中移除该点。重复

2016-02-16 17:04:03 2893

原创 JDK的快速排序算法实现DualPivotQuicksort

从JDK7开始采用这种双Pivot的快速排序算法,这种算法通常会比传统单Pivot的快排算法效率更高。 具体流程如下: 1.需要排序的数组为a,判断数组的长度是否大于286,大于使用归并排序(merge sort),否则执行2。 2.判断数组长度是否小于47,小于则采用插入排序,否则执行3。 3.采用近似算法计算数组长度的1/7int seventh = (length >> 3) + (

2016-02-15 18:26:23 3337

转载 Java中弹出对话框的方法

1.显示一个错误对话框,该对话框显示的 message 为 ‘alert’:JOptionPane.showMessageDialog(null, "alert", "alert", JOptionPane.ERROR_MESSAGE); 2.显示一个内部信息对话框,其 message 为 ‘information’: JOptionPane.showInternalMessageDialog(fr

2016-02-15 15:45:27 3238

原创 Java正则表达式简单用法

1.简单查找String target="var tips=\"认证成功<br>用户名:XXXX<br>IP地址:1.1.1.1\"";Pattern pattern = Pattern.compile("IP地址:[\\w\\.]+\"");Matcher matcher = pattern.matcher(target);String result;if (matcher.find())

2016-02-15 15:29:43 784

空空如也

空空如也

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

TA关注的人

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