自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

cfanr

对贡献有激情,对回报有信心!

  • 博客(43)
  • 资源 (1)
  • 收藏
  • 关注

原创 Cracking the coding interview--Q8.6

题目原文:Implement the “paint fill” function that one might see on many image editing programs. That is, given a screen (represented by a 2-dimensional array of Colors), a point, and a new color, fill

2014-02-28 11:55:42 1406

转载 做leetcode的几点体会分享

我跟大家一样,都做过leetcode,还不止一遍,现在想跟大家分享一下我做leetcode的一些体会。1 大部分题目你都是可以自己做出来的。所以,第一遍尽量不要网上找答案;2 写了的不管通过的,不通过的答案要保存下来。不通过的,也要记录下来哪儿没有通过。很有可能你这次错了,不知道怎么搞过了,下次还是错;3 一定要手写几遍,手写远远比在机器上印象深刻;4 写c

2014-02-28 11:09:26 1108

原创 Cracking the coding interview--Q8.5

题目原文:Implement an algorithm to print all valid (e.g., properly opened and closed) combinations of n-pairs of parentheses.EXAMPLE:input: 3 (e.g., 3 pairs of parentheses)output: ()()(), ()(())

2014-02-27 11:14:25 1463

转载 十年学会程序设计

本文转自:徐宥博客http://blog.youxu.info/21-days/为何大家如此匆忙?走进任何一家书店,你会看到书架上一排不见尽头的放着如 以及几天或者几小时学会Windows, 因特网或者Visual Basic 这类书。我在Amazon 网上书店用一下的方式进行高级搜索:出版年份: 1992以后 书名包括:“天” 和 “学习” 或 “自学”

2014-02-27 09:22:31 1029

转载 佛教艺术中的沙

本文转自:徐宥的博客:http://blog.youxu.info/2012/10/24/sands-in-buddhism/“沙” 是佛教里很值得一提的物件,很多佛教艺术都和沙有关。日本禅宗的“枯山水”就是一种依赖于沙的园林艺术。枯山水在西方很有名,以至于在西方直接被称为禅花园(Zen Garden)。一般的园林都会通过假山和水构景,通过人造的山和水,来引起观者自然的联想

2014-02-27 08:49:43 2278

原创 Cracking the coding interview--Q8.4

题目原文:Write a method to compute all permutations of a string.译文:写一个方法返回一个字符串的所有排列。解答显然对于一个长度为n的串,它的全排列共有A(n, n)=n!种,由递归的方法解,若字符串是“abc”,函数名为recursionPermu,由不同的递归思路分析。解法一:将第0个字符a取出,递归调用re

2014-02-26 21:20:16 1253

原创 Cracking the coding interview--Q8.3

题目原文:Write a method that returns all subsets of a set.译文:写一个方法返回一个集合的所有子集合。解答对于一个集合,它的总共子集数为2^n(包括空集)。对于S(5)={1,2,3,4,5},则S(5)的子集数可以写为:5与S(4)的子集的组合+S(4)的子集,得递归算法如下: public static Linke

2014-02-25 13:08:27 1798

原创 Cracking the coding interview--Q8.2

题目原文:Imagine a robot sitting on the upper left hand corner of an NxN grid. The robot can only move in two directions: right and down. How many possible paths are there for the robot?FOLLOW UPI

2014-02-25 11:04:42 1368

原创 Cracking the coding interview--Q8.1

题目原文:Write a method to generate the nth Fibonacci number.译文:写一个方法产生第n个斐波那契数。解答斐波那契数列(又称黄金分割数列)指的是这样一个数列 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...特别指出:0是第0项,不是第1项。这个数列从第二项开始

2014-02-23 11:24:38 1280

原创 Cracking the coding interview--Q5.7

题目原文:An array A[1... n] contains all the integers from 0 to n except for one number which is missing. In this problem, we cannot access an entire integer in A with a single operation. The elements

2014-02-22 23:30:13 1508

原创 Cracking the coding interview--Q5.6

题目原文:Write a program to swap odd and even bits in an integer with as few instructions as possible (e.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped, etc).译文:写程序用尽可能少的指令实现对一个整数的

2014-02-22 17:07:26 1320

原创 Cracking the coding interview--Q5.5

题目原文:Write a function to determine the number of bits required to convert integer A to integer B.Input: 31, 14Output: 2译文:写一个函数计算出将一个整数A转换到整数B需要修改多少个二进制位。解答首先要理解题目要求的是计算出整数A转换到整数B需要修

2014-02-20 10:51:25 1433

原创 Cracking the coding interview--Q5.4

题目原文:Explain what the following code does: ((n & (n-1)) == 0).译文:解释下面代码的作用:((n&(n-1))==0)解答分析:首先该代码是一个位运算的式子,两个相邻的数作按位与运算得到0,而当两个二进制的各位不同时,作按位与运算才会等于0,所以只有当n为2的整数次幕时,比它小1的数的二进制的各位才会与它的二进

2014-02-19 17:31:47 1233

转载 位运算n & (n-1)的妙用

本文转自:http://blog.csdn.net/zheng0518/article/details/8882394按位与的知识n&(n-1)作用:将n的二进制表示中的最低位为1的改为0,先看一个简单的例子:n = 10100(二进制),则(n-1) = 10011 ==》n&(n-1) = 10000可以看到原本最低位为1的那位变为0。弄明白了n

2014-02-19 17:28:58 25684 2

原创 Cracking the coding interview--Q5.3

题目原文:Given an integer, print the next smallest and next largest number that have the same number of 1 bits in their binary representation.译文:给一个整数,打印两个数,并且他们的二进制表示中的1的个数和这个整数的一样,其中一个是比该数大的数中

2014-02-19 12:05:54 1336

原创 内向者性格&&安静的力量

前言:作为搞IT技术的,相信很多人都是比较内向的,以下文章正是介绍内向者的,希望大家能够从中认识自己,接受自己……    “外向的人更倾向从外部世界寻找力量,而内向的人更倾向关注自己的内部世界”——《安静:内向性格的竞争力》    “幸福快乐的首要之点,就在于一个人愿意成为他自己”——《内向者优势: 如何在外向的世界中获得成功》        据说性格外向和内向的比

2014-02-19 11:13:08 4156 3

转载 《Java编程思想》学习——按位运算符、移位运算符

转自:http://www.cnblogs.com/echolxl/p/3164990.html(第三章)(一)按位运算符按位逻辑运算符有:“与”(AND)        &        (同1为1,否则为0)1&1=1;1&0=0;0&0=0“或”(OR) |                  (有1为1,否则为0)1|1=1;1|0

2014-02-18 16:44:20 1194

原创 C语言运算符优先级表

基础知识,熟记!表如下:优先级运算符名称或含义结合方向说明1[]数组下标左到右 ()圆括号 .成员选择(对象) ->成员选择(指针)

2014-02-18 13:37:34 1380

原创 Cracking the coding interview--Q5.2

题目原文:Given a (decimal - e.g. 3.72) number that is passed in as a string, print the binary representation. If the number can not be represented accurately in binary, print “ERROR”译文:给一个字符类型表示

2014-02-17 21:49:05 1197

原创 Cracking the coding interview--Q5.1

题目原文:You are given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to set all bits between i and j in N equal to M (e.g., M becomes a substring of N located at i and st

2014-02-15 21:45:14 1365

原创 Cracking the coding interview--Q4.8

题目原文:You are given a binary tree in which each node contains a value. Design an algorithm to print all paths which sum up to that value. Note that it can be any path in the tree - it does not have

2014-02-15 20:35:14 1646 1

原创 Cracking the coding interview--Q4.7

题目原文:You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of T1.译文:有两个非常大的二叉树:T1,有上百万个结点,T2,有上百个

2014-02-15 14:27:07 1332

原创 Cracking the coding interview--Q4.6

题目原文:Design an algorithm and write code to find the first common ancestor of two nodes in a binary tree. Avoid storing additional nodes in a data structure. NOTE: This is not necessarily a binary

2014-02-14 23:51:15 1254

原创 Cracking the coding interview--Q4.5

题目原文:Write an algorithm to find the ‘next’ node (e.g., in-order successor) of a given node in a binary search tree where each node has a link to its parent.译文:给定一个二叉查找树的结点,写一个算法去找“next”结点(即中

2014-02-14 22:33:25 1144

原创 Cracking the coding interview--Q4.4

题目原文:Given a binary search tree, design an algorithm which creates a linked list of all the nodes at each depth (eg, if you have a tree with depth D, you’ll have D linked lists).译文:给一个二叉查找树,

2014-02-11 22:20:48 1221

原创 Cracking the coding interview--Q4.3

题目原文:Given a sorted (increasing order) array, write an algorithm to create a binary tree with minimal height.译文:给一个已经排好序(增序)的数组,写一个算法创建一个具有最小高度二叉树。解答要使二叉树高度最小,则其左右结点数应相当。那么将数组对半分,以中间数为父结

2014-02-11 21:18:08 1186

原创 Cracking the coding interview--Q4.2

题目原文:Given a directed graph, design an algorithm to find out whether there is a route between two nodes.译文:给一个有向图,设计一个算法去找出两个结点间是否有路径.解答方法

2014-02-10 10:01:18 1283

原创 Cracking the coding interview--Q4.1

题目原文:Implement a function to check if a tree is balanced. For the purposes of this question, a balanced tree is defined to be a tree such that no two leaf nodes differ in distance from the root

2014-02-09 00:02:30 1652 1

原创 Cracking the coding interview--Q3.6

题目原文:Write a program to sort a stack in ascending order. You should not make any assumptions about how the stack is implemented. The following are the only functions that should be used to write

2014-02-07 23:25:14 1260

原创 Java集合框架基础

Java Collections Framework是java很常用和重要的一个知识点,它的所有类和接口都在java.util包中。集合中只能保存对象(保存对象的引用变量)。(数组既可以保存基本类型的数据也可以保存对象)。       当我们把一个对象放入集合中后,系统会把所有集合元素都当成Object类的实例进行处理。从JDK1.5以后,这种状态得到了改进:可以使用泛型来限制集合里元素的类型

2014-02-07 22:16:51 1031

转载 Google Java编程风格指南

转自:作者:Hawstein出处:http://hawstein.com/posts/google-java-style.html声明:本文采用以下协议进行授权: 自由转载-非商用-非衍生-保持署名|Creative Commons BY-NC-ND 3.0 ,转载请注明作者及出处。目录前言源文件基础源文件结构格式命名约定编程实践Javadoc后记

2014-02-07 19:33:22 1113

原创 Cracking the coding interview--Q3.5

题目原文:Implement a MyQueue class which implements a queue using two stacks.译文:用两个栈实现一个队列MyQueue。解答方法

2014-02-06 22:27:13 1304

转载 计算机科学中最重要的32个算法

本文转自:http://www.infoq.com/cn/news/2012/08/32-most-important-algorithms奥地利符号计算研究所(Research Institute for Symbolic Computation,简称RISC)的Christoph Koutschan博士在自己的页面上发布了一篇文章,提到他做了一个调查,参与者大多数是计算机科

2014-02-05 22:41:49 934

原创 Cracking the coding interview--Q3.4

题目原文:In the classic problem of the Towers of Hanoi, you have 3 rods and N disks of different sizes which can slide onto any tower. The puzzle starts with disks sorted in ascending order of size fr

2014-02-05 22:26:05 1249

原创 Cracking the coding interview--Q3.3

题目原文:Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we would likely start a new stack when the previous stack exceeds some threshold. Im

2014-02-05 22:15:02 1256

原创 Cracking the coding interview--Q3.2

题目原文:How would you design a stack which, in addition to push and pop, also has a function min which returns the minimum element? Push, pop and min should all operate in O(1) time.译文:设计一个栈,除了

2014-02-05 18:01:42 1233

原创 Cracking the coding interview--Q3.1

题目原文:Describe how you could use a single array to implement three stacks.译文:描述怎样用一个单独的数组来实现三个栈。解答解法一:将数组划分成3等份,每一份独立的用来实现堆栈。*第一个堆栈:从 0     至 n/3*第二个堆栈:从 n/3  至 2n/3*第三个堆栈:从2n/3 至

2014-02-05 15:55:36 1328

原创 Cracking the coding interview--Q2.5

题目原文:Given a circular linked list, implement an algorithm which returns node at the beginning of the loop.DEFINITIONCircular linked list: A (corrupt) linked list in which a node’s next pointer

2014-02-05 11:47:49 1183

原创 Cracking the coding interview--Q2.4

题目原文:You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1’s digit is at the head of the list. Write a

2014-02-04 23:40:31 1178

原创 Cracking the coding interview--Q2.3

题目原文:Implement an algorithm to delete a node in the middle of a single linked list, given only access to that node.EXAMPLEInput: the node ‘c’ from the linked list a->b->c->d->eResult: nothin

2014-02-04 21:04:24 1251

java连接数据库的demo(包括sql、mysql)

这是java直接连接sql、mysql数据库的demo

2014-01-04

空空如也

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

TA关注的人

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