- 博客(10)
- 资源 (3)
- 收藏
- 关注
原创 【leetcode】将整数取反,-321返回-123(Reverse Integer)
题目描述如下:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321一目了然,知道了题目的意思了。。下面给出的我一开始的想法public int reverse(int num){ StringBuilder sb=new String
2013-12-28 23:04:40 2864 1
原创 【leetcode】在一堆每个数字都出现三次的数组中,找到那个只出现一次的数(Single Number II)
题目的描述是这样的:Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it wit
2013-12-28 19:38:32 5468
原创 【leetcode】非递归先序遍历二叉树(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 / 3return [1,2,3].Note: R
2013-12-25 11:31:53 2061
原创 【leetcode】比较两棵二叉树是否相同(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.
2013-12-23 22:46:54 2983
原创 【leetcode】数组中找出只出现一次的数字(Single Number)
题目是这样说的: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 wit
2013-12-23 12:28:08 2248
原创 一段代码让你理解二叉树的递归奥秘
class TreeNode{ TreeNode left; TreeNode right; int val; TreeNode(int val){ this.val=val; } static void scanNodes(TreeNode root){ if(root!=null){ System.out.println("this is node :"+root
2013-12-23 10:21:12 4559 1
原创 【leetcode Java】二叉树的递归遍历以及最大深度的求解(Java)
递归是非常神奇的方法,代码看起来很简洁。对二叉树的遍历和求最大深度可以用递归的方法,主要思路就是遍历左子树,再遍历右子树。如果左子树上面的结点,有右孩子,则调用右子树的方法;遍历到左子树的叶节点的时候,返回,开始遍历右子树。如果右子树上面的结点有左孩子,则调用左子树的方法,遍历到右子树的叶子结点的时候,程序结束。static void scanNodes(TreeNode root){ i
2013-12-20 09:36:25 11347
转载 http头部解析
一、基础篇HTTP(HyperTextTransferProtocol) 是超文本传输协议的缩写,它用于传送WWW方式的数据,关于HTTP协议的详细内容请参考RFC2616。HTTP协议采用了请求/响应模型。客户端向服 务器发送一个请求,请求头包含请求的方法、URI、协议版本、以及包含请求修饰符、客户信息和内容的类似于MIME的消息结构。服务器以一个状态行作为响 应,相应的内容包括消息协议的版
2013-12-05 12:39:21 2752
翻译 提取表和子查询的区别(derived table vs subqueries)
子查询,大家再熟悉不过了,例如:select employee_namefrom employeewhere employee_salary >(select avg(employee_salary)from employee)下面这也是一个子查询,没用到where语句。INSERT INTO math_study_group(id, name)SELECT
2013-12-05 12:06:08 3188
原创 mysql如何删除重复记录
方法有很多,除了最简便的,alter ignore table 表名 add UNIQUE index(字段名);然后再将索引drop掉,这个方法外。更加中规中矩的方法也是有的。。比如我在网上搜到的:delete from people where peopleId in (select peopleId from people group by peop
2013-12-04 18:56:28 1477
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人