自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

-琥珀-的专栏

格言:抱怨没有用,一切靠自己!!

  • 博客(26)
  • 资源 (4)
  • 问答 (1)
  • 收藏
  • 关注

原创 Min Stack(返回栈中最小数)

Min Stack(返回栈中最小数)Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack. pop() – Removes the element on top of the stack.

2015-06-29 21:31:14 570

原创 输入一棵二叉树,判断该二叉树是否是平衡二叉树。

输入一棵二叉树,判断该二叉树是否是平衡二叉树。 题目描述 输入一棵二叉树,判断该二叉树是否是平衡二叉树。Code/*public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { th

2015-06-27 13:50:54 808

原创 Reverse Integer (数字反转)

Reverse Integer Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321陷阱java int 的范围为 -2147483648->214748364710 如果超出则溢出Codepublic class Solution {

2015-06-27 12:18:07 675

原创 Count Complete Tree Nodes (求完全二叉树节点树)

Count Complete Tree Nodes Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia: In a complete binary tree every level, except possibly

2015-06-27 09:59:22 868

原创 Summary Ranges(数组中连续的数字段)

Summary Ranges Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return [“0->2”,”4->5”,”7”].CODEpublic class Solution { pu

2015-06-26 11:53:18 832

原创 Same Tree (判断树是否相等)

Same Tree 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.

2015-06-25 21:44:13 687

原创 Binary Tree Postorder Traversal

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 / 3

2015-06-25 21:30:56 488

原创 Maximal Square

Maximal Square ‘ Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing all 1’s and return its area. For example, given the following matrix: 1 0 1 0 0 1 0

2015-06-25 21:12:51 516

原创 [编程题]数组中出现次数超过一半的数字

[编程题]数组中出现次数超过一半的数字 数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字。例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}。由于数字2在数组中出现了5次,超过数组长度的一半,因此输出2。没有找到输出为0。思路首先进行快排 如果 a[i]==a[i+array.length/2] 则返回a[i] 循环 array.length/2次代码public

2015-06-23 21:14:05 532

原创 求二叉树深度(递归方式)

求二叉树深度(递归方式)int FindTreeDeep(BinTree BT){ int deep=0; if(BT!=null){ int left=FindTreeDeep(BT.left); int right=FindTreeDeep(BT.right); deep=left>right?left+1:right+1; }

2015-06-23 19:37:24 846

原创 堆排序(最小的K个数)

堆排序(最小的K个数)题目描述 输入n个整数,找出其中最小的K个数。例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,。代码import java.util.ArrayList;public class Solution { public ArrayList<Integer> GetLeastNumbers_Solution(int [] input

2015-06-23 11:00:07 640

原创 快速排序分析

快速排序首先简单描述一下快速排序 1. 快速排序树不稳定的(由于关键字的比较与交换是跳跃进行的) 2. 时间复杂度为o(n*logn) (最好情况为n*logn 若数组基本有序为n*n) 3. 空间复杂度为logn (主要是递归造成的栈空间的使用,最好情况,递归树的深度为log2n,其空间复杂度也就为O(logn),最坏情况,需要进行n‐1递归调用,其空间复杂度为O(n),平均情况,空间复杂

2015-06-22 10:48:56 636

原创 二叉搜索树的第k个结点

二叉搜索树的第k个结点题目描述 给定一颗二叉搜索树,请找出其中的第k大的结点。例如, 5 / \ 3 7 /\ /\ 2 4 6 8 中,按结点数值大小顺序第三个结点的值为4。代码/*public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public T

2015-06-22 09:28:14 1061

原创 两个链表的第一个公共结点

两个链表的第一个公共结点题目描述 输入两个链表,找出它们的第一个公共结点代码/* public class ListNode { int val; ListNode next = null;ListNode(int val) { this.val = val;}} */ public class Solution {public ListNode Find

2015-06-20 12:04:37 514

原创 [编程题]链表中环的入口结点

[编程题]链表中环的入口结点题目描述 一个链表中包含环,请找出该链表的环的入口结点。解题思路如何找到环的入口节点呢如果我们一直next next 显然由于出现了环会一直访问下去 显然我们需要解决环的问题 如果我们访问一个节点再把它删除掉呢?就是截断两个相邻节点的关系。next=null;所以我们需要两个箭头 一前一后 代码如下代码/* public class ListNode {

2015-06-19 21:27:30 749

原创 对称的二叉树判断

对称的二叉树判断题目描述 请实现一个函数,用来判断一颗二叉树是不是对称的。注意,如果一个二叉树同此二叉树的镜像是同样的,定义其为对称的。代码/*public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) {

2015-06-18 21:34:31 564

原创 java中Math.round(),Math.ceil(),Math.floor()运算

java中Math.round(),Math.ceil(),Math.floor()运算该运算结果只限于再java中C++中就不是该结果了 java中Math.round(X) =(long)Math.floor(X+0.5);C++运算结果

2015-06-18 16:39:02 1974

原创 二叉树中和为某一值的路径

二叉树中和为某一值的路径题目描述 输入一颗二叉树和一个整数,打印出二叉树中结点值的和为输入整数的所有路径。路径定义为从树的根结点开始往下一直到叶结点所经过的结点形成一条路径。代码/*public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public Tr

2015-06-16 21:52:41 612

原创 链表中倒数第k个结点

链表中倒数第k个结点题目描述 输入一个链表,输出该链表中倒数第k个结点。代码/*public class ListNode { int val; ListNode next = null; ListNode(int val) { this.val = val; }}*/public class Solution { public L

2015-06-15 21:03:38 530

原创 从上往下打印二叉树

从上往下打印二叉树题目描述 从上往下打印出二叉树的每个节点,同层节点从左至右打印。代码/*public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; }

2015-06-15 20:15:41 537

原创 重建二叉树(根据前序中序遍历构建二叉树)

重建二叉树(根据前序中序遍历构建二叉树)题目描述 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并输出它的后序遍历序列。(测试用例中,”树”的输出形式类似于树的层次遍历,没有节点的用#来代替)代码/** * De

2015-06-15 19:44:29 630

原创 二叉搜索树的后序遍历序列

二叉搜索树的后序遍历序列题目描述 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果。如果是则输出Yes,否则输出No。假设输入的数组的任意两个数字都互不相同。public class Solution { public boolean VerifySquenceOfBST(int [] sequence) { return VerifySquenceOfBS

2015-06-14 22:05:47 565

原创 输入一个二叉树,输出其镜像(二叉树反转)

输入一个二叉树,输出其镜像(二叉树反转)/*public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; }}*/public class Solution

2015-06-13 13:02:33 1874

原创 输入两颗二叉树A,B,判断B是不是A的子结构

输入两颗二叉树A,B,判断B是不是A的子结构。public class Solution { public boolean HasSubtree(TreeNode root1,TreeNode root2) { boolean result=false; if(root1!=null&&root2!=null){ if(root1.va

2015-06-13 12:49:19 1722 1

原创 [编程题] 奇数位上都是奇数或者偶数位上都是偶数

[编程题] 奇数位上都是奇数或者偶数位上都是偶数给定一个长度不小于2的数组arr。 写一个函数调整arr,使arr中要么所有的偶数位上都是偶数,要么所有的奇数位上都是奇数上。 要求:如果数组长度为N,时间复杂度请达到O(N),额外空间复杂度请达到O(1),下标0,2,4,6…算作偶数位,下标1,3,5,7…算作奇数位,例如[1,2,3,4]调整为[2,1,4,3]即可public class Sol

2015-06-06 20:17:50 737

转载 社交网络中校花评比算法(转自百度百科)

社交网络中校花评比算法埃洛等级分系统埃洛等级分系统是指由匈牙利裔美国物理学家阿帕德·埃洛创建的一个衡量各类对弈活动水平的评价方法,是当今对弈水平评估的公认的权威方法。被广泛用于国际象棋、围棋、足球、篮球等运动。 该系统基于统计学的一个评估棋手水平的方法。美国国际象棋协会在1960年首先使用这种计分方法。由于它比先前的方法更公平客观,这种方法很快流行开来。1970年国际棋联正式开始使用这个系统。[1

2015-06-02 08:38:18 1581

struts2 spring hibernate框架技术与项目实战 光盘源码 中

struts2 spring hibernate框架技术与项目实战 光盘源码 中 资源150M必须分成3部分上中下

2015-06-04

struts2 spring hibernate框架技术与项目实战 光盘源码上

struts2 spring hibernate框架技术与项目实战 光盘源码 上 资源150M必须分成3部分上中下

2015-06-04

service receiver notification播放器

service receiver notification播放器

2015-04-14

Refreshlistview

仿超级课程表下拉刷新

2015-04-03

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

TA关注的人

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