- 博客(14)
- 收藏
- 关注
原创 LeetCode -- InsertionSor List
Sort a linked list using insertion sort. /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x;
2014-07-17 22:38:49
468
原创 LeetCode -- ReverseWordsinaString
Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the". 这里有两种qing
2014-07-15 20:24:35
383
原创 LeetCode -- LinkedListCycle
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space?
2014-07-14 22:12:53
416
原创 LeetCode -- UniqueBinarySearchTrees
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. 当n = 0 时为空树,所以BST的个数为1 当n = 1 时只有一个节点,
2014-07-14 21:12:19
382
原创 LeetCode -- ReverseInteger
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321
2014-07-14 19:30:32
385
原创 LeetCode -- sameTree
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. 采用先序遍历的思想,
2014-07-10 23:19:47
481
原创 LeetCode -- maxDepth
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. 比较左右子树的高度,选最高的叠加
2014-07-10 23:14:19
514
原创 LeetCode -- singleNumber
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 e
2014-07-10 23:07:56
378
原创 java-随机数的产生
产生随机数的方式: Math.random()产生随机数,产生的是0-1之间的double,如果要得到其他范围之类的,就乘上一个系数 在java.util包里面提供了一个Random类,可以通过Random的对象来产生随机数。java.util.Random类有两种不同的构建方式:带种子和不带种子 不带种子: 没有提供种子数,Random实例的种子数将是当前时间的毫秒数
2014-04-12 12:31:29
698
原创 POJ-1003-HangOver
Description How far can you make a stack of cards overhang a table? If you have one card, you can create a maximum overhang of half a card length. (We're assuming that the cards must be perpendicul
2014-01-16 17:16:58
471
原创 1004西西弗斯式的命运
Description 古希腊有个关于西西弗斯的神话: 西西弗斯被众神判决推运一块石头至山顶。由于巨石本身的重量,它被推到山顶却又总要滚下山脚。于是西西弗斯又得把石块推上山去。如此反复,永无止境,没有尽头。众神认为,让西西弗斯服这永恒的劳役是最严酷的惩罚。 二哥被押入地狱。他被众神判决扛着一块巨砖在山路上走,再原路返回,如此反复,没有尽头。 众神规定二哥独自走山路的时间不得
2013-04-25 17:18:07
1197
原创 1003二哥养细菌
题目描述 二哥不仅种苹果和花生,还养了很多细菌。二哥的细菌培养皿成方格形,边长为L。长期培养后,二哥发现了细菌繁殖的规律:最初每个格子里的细菌及其后代都会独立繁殖,每次繁殖都会在其上下左右四个相邻的格子里产生新的细菌,而已经存在的细菌在培养皿充满细菌之前都不会死亡。另外,有一些格子里可能还有抗生素,细菌在有抗生素的格子里无法繁殖。 二哥于是发明了一个游戏:取一个新的培养皿,在某些格子里
2013-04-25 17:16:57
1370
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅