上一页 1 2 3 4 5 6 7 8 9 ··· 14 下一页

2013年12月20日

Iterator

摘要: java.utilInterface IteratorType Parameters:E- the type of elements returned by this iteratorbooleanhasNext()Returnstrueif the iteration has more elements.Enext()Returns the next element in the iteration.voidremove()Removes from the underlying collection the last element returned by this iterator (op 阅读全文

posted @ 2013-12-20 04:55 Step-BY-Step 阅读(396) 评论(0) 推荐(0) 编辑

recursion lead to out of memory

摘要: There are two storage areas involved: thestackand the heap. The stack is where the currentstateof a method call is kept (ie local variables and references), and the heap is where objects are stored.The Hotspot documentationsays that on Linux 64-bit each thread has a stack of 1024kB by default. The h 阅读全文

posted @ 2013-12-20 01:30 Step-BY-Step 阅读(151) 评论(0) 推荐(0) 编辑

2013年12月13日

引用 和 指针

摘要: 从概念上讲。指针从本质上讲就是存放变量地址的一个变量,在逻辑上是独立的,它可以被改变,包括其所指向的地址的改变和其指向的地址中所存放的数据的改变。而引用是一个别名,它在逻辑上不是独立的,它的存在具有依附性,所以引用必须在一开始就被初始化,而且其引用的对象在其整个生命周期中是不能被改变的(自始至终只能依附于同一个变量)。在C++中,指针和引用经常用于函数的参数传递,然而,指针传递参数和引用传递参数是有本质上的不同的:指针传递参数本质上是值传递的方式,它所传递的是一个地址值。值传递过程中,被调函数的形式参数作为被调函数的局部变量处理,即在栈中开辟了内存空间以存放由主调函数放进来的实参的值,从而成为 阅读全文

posted @ 2013-12-13 02:32 Step-BY-Step 阅读(218) 评论(0) 推荐(0) 编辑

2013年12月12日

人生最值得你去做的30件事

摘要: 心理导读:人生最值得你去做的30件事,一份积极的待办事项清单,从今天开始,创造你的美好未来吧。 ——www.xinli001.com 1、与对的人分享你的时间。这些“对的人”就是爱你、欣赏你、鼓励你的人,和他们在一起让你感到很舒适。他们的存在让你感觉自己的人生更加鲜活,他们不仅接受现在的你,还接受并帮助你成为你想成为的那一个人,而且是无条件的。 2、直面难题,勇往直前。并不是你所面临的困境决定了你是什么样的人,而是你对此作出的回应决定了你是怎样的人。除非你采取行动,否则难题是不会自行消失的。在恰当的时间去做你力所能及的事,你就会收获成果。千里之行,始于足下。成功的本质就是朝着正确的方向... 阅读全文

posted @ 2013-12-12 14:27 Step-BY-Step 阅读(200) 评论(0) 推荐(0) 编辑

能拯救你的,只有你自己

摘要: 心理导读:二十岁出头的年轻人,往往抱着浮躁急功近利的心走在路上,然而,你不知道自己究竟想要什么,要去哪里,只是想过想象中美好的生活,渴望着早日实现梦想,但成长、成功是一个一个时辰熬出来的。——xinli001.com1、我们都过着与想象不一样的生活 读书的时候,每天骑着脚踏车上学放学,等着中考结束成为高中生,等着高考结束成为大学生,等着考研结束把书一条龙念完,即便目标明确,其实你一直很迷茫;找工作的时候,满是热血,四处投递简历石沉大海后,在家里守在电话机旁等面试通知常常很无助,你心想着工作稳定了一切都好了;有了份工作,每天上班挤在拥挤地铁的人潮中感到很落寞,整日穿得人模人样说话圆滑得体,其实你 阅读全文

posted @ 2013-12-12 14:21 Step-BY-Step 阅读(263) 评论(0) 推荐(0) 编辑

Chp17: Moderate

摘要: 17.1 swap a number in place.(without temporary variables)a = a ^ b;b = a ^ b;a = a ^ b;17.3 Write a function which computes the number of trailing zeros in n factorial.To count the number of zeros, we only need to count the pairs of multiples of 5 and 2. There will always be more multiples of 2 than 阅读全文

posted @ 2013-12-12 02:51 Step-BY-Step 阅读(212) 评论(0) 推荐(0) 编辑

Chp14: Java

摘要: 1.finally keyword:finally keyword is used in association with a try/catch block and guarantees that a section of code will be executed, even if an exception is thrown. The finally block will be executed after the try and catch blocks, but before control transfers back to its origin.2. Overloading vs 阅读全文

posted @ 2013-12-12 02:49 Step-BY-Step 阅读(126) 评论(0) 推荐(0) 编辑

2013年12月11日

Chp12: Testing

摘要: What the Interviewer is Looking for:Big Picture UnderstandingKnowing How the Pieces Fit TogetherOrganizationParcticalityTesting a Function:Define the test casenormal caseExtremes: empty array? very small? very large?Nulls and "illegal" inputStrange input 阅读全文

posted @ 2013-12-11 03:41 Step-BY-Step 阅读(122) 评论(0) 推荐(0) 编辑

Chp11: Sorting and Searching

摘要: Common Sorting Algo:Bubble Sort: Runime: O(n2) average and worst case. Memory: O(1).1 void BubbleSortArray(){ 2 for(int i=1;ia[j+1]){//比较交换相邻元素 5 int temp; 6 temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; 7 } 8 } Selection Sort:Runtime: O(n2) average and worst case. Memo... 阅读全文

posted @ 2013-12-11 03:27 Step-BY-Step 阅读(446) 评论(0) 推荐(0) 编辑

常见的排序算法之Java代码解释

摘要: 一 简要介绍一般排序均值的是将一个已经无序的序列数据重新排列成有序的常见的排序分为:1插入类排序主要就是对于一个已经有序的序列中,插入一个新的记录。它包括:直接插入排序,折半插入排序和希尔排序2交换类排序这类排序的核心就是每次比较都要“交换”,在每一趟排序都会两两发生一系列的“交换”排序,但是每一趟排序都会让一个记录排序到它的最终位置上。它包括:起泡排序,快速排序3 选择类排序每一趟排序都从一系列数据中选择一个最大或最小的记录,将它放置到第一个或最后一个为位置交换,只有在选择后才交换,比起交换类排序,减少了交换记录的时间。属于它的排序:简单选择排序,堆排序4 归并类排序将两个或两个以上的有序序 阅读全文

posted @ 2013-12-11 02:47 Step-BY-Step 阅读(262) 评论(0) 推荐(0) 编辑

Chp10: Scalability and Memory Limits

摘要: The Step-by-Step Approachbreak down a tricky problem and to solve problems using what you do know.Step 1: Make BelievePretend that the data can all fit on one machine and there are no memory limitations. Provide the general outline for your solution.Step 2: Get Realfigure out how to logically divide 阅读全文

posted @ 2013-12-11 02:04 Step-BY-Step 阅读(211) 评论(0) 推荐(0) 编辑

2013年12月9日

Java中的泛型方法

摘要: 泛型是什么意思在这就不多说了,而Java中泛型类的定义也比较简单,例如:public class Test{}。这样就定义了一个泛型类Test,在实例化该类时,必须指明泛型T的具体类型,例如:Test t = new Test();,指明泛型T的类型为Object。 但是Java中的泛型方法就比较复杂了。 泛型类,是在实例化类的时候指明泛型的具体类型;泛型方法,是在调用方法的时候指明泛型的具体类型。转自: http://www.cnblogs.com/iyangyuan/archive/2013/04/09/3011274.html 定义泛型方法语法格式如下:调用泛型方法语法格式如下: 说明一 阅读全文

posted @ 2013-12-09 14:53 Step-BY-Step 阅读(266) 评论(0) 推荐(0) 编辑

Chp5: Bit Manipulation

摘要: Bits Facts and Tricksx ^ 0s = xx & 0s = 0x | 0s = xx ^ 1s = ~xx & 1s = xx | 1s = 1sx ^ x = 0x & x = xx | x = xCommon Bit Tasks: Get, Set, Clear And UpdateGet:num & (1 > 1) | ((x & 0x55555555) << 1) );4 } 阅读全文

posted @ 2013-12-09 08:33 Step-BY-Step 阅读(207) 评论(0) 推荐(0) 编辑

程序人生的四个象限和两条主线

摘要: 转自: http://ftqq.com/2013/12/coding-life/程序人生的四个象限和两条主线59条评论零为什么我们要自己做职业生涯规划?记得电影《社交网络》里边,CFO同学在知道自己股权被稀释时说了一句话,“我以为那些律师是我的律师。”其实我们大多数人对HR几乎都存在类似的误解—— 你以为她是你的HR,其实她只是公司的HR。她们care的是如何编个理由用老板给的那点小钱留住一个高性价比的人才,而不是真正有助于你发展的职业路线图。昨天还含情脉脉和你讨论人生的知心姐姐明天就可能变成拿着劳动合同逼你主动离职的凶婆娘。和人性无关——这就是她们的工作,越专业的HR越擅长。所以,你要自己来 阅读全文

posted @ 2013-12-09 08:10 Step-BY-Step 阅读(199) 评论(0) 推荐(0) 编辑

2013年12月8日

override equals in Java

摘要: equals()(javadoc) must define an equality relation (it must bereflexive,symmetric, andtransitive). In addition, it must beconsistent(if the objects are not modified, then it must keep returning the same value). Furthermore,o.equals(null)must always return false.hashCode()(javadoc) must also beconsis 阅读全文

posted @ 2013-12-08 03:07 Step-BY-Step 阅读(968) 评论(0) 推荐(0) 编辑

Yahoo 面经

该文被密码保护。 阅读全文

posted @ 2013-12-08 02:43 Step-BY-Step 阅读(4) 评论(0) 推荐(0) 编辑

2013年12月7日

单态模式

摘要: Singleton模式主要作用是保证在面向对象编程语言设计编写的程序中,一个类Class只有一个实例存在。在很多操作中,比如建立目录 数据库连接都需要这样的单线程操作。还有, singleton能够被状态化; 这样,多个单态类在一起就可以作为一个状态仓库一样向外提供服务,比如,你要论坛中的帖子计数器,每次浏览一次需要计数,单态类能否保持住这个计数,并且能synchronize的安全自动加1,如果你要把这个数字永久保存到数据库,你可以在不修改单态接口的情况下方便的做到。另外方面,Singleton也能够被无状态化。提供工具性质的功能,Singleton模式就为我们提供了这样实现的可能。使用Sin 阅读全文

posted @ 2013-12-07 02:55 Step-BY-Step 阅读(229) 评论(0) 推荐(0) 编辑

Chp18: Hard

摘要: 18.1 Write a function that adds two numbers. You should not use + or any arithmetic operators.Solution: deal with 759 + 674.1. add 759 + 674, but forget to carry. get 3232. add 759 + 674, but only do the carrying, rather than the addition of each digit. get 11103. add the result of the first two ope 阅读全文

posted @ 2013-12-07 02:27 Step-BY-Step 阅读(210) 评论(0) 推荐(0) 编辑

2013年12月6日

内存泄漏 和 内存溢出

摘要: 在计算机科学中,内存泄漏(memory leak)指由于疏忽或错误造成程序未能释放已经不再使用的内存的情况。内存泄漏并非指内存在物理上的消失,而是应用程序分配某段内存后,由于设计错误,失去了对该段内存的控制,因而造成了内存的浪费。内存泄漏与许多其他问题有着相似的症状,并且通常情况下只能由那些可以获得程序源代码的程序员才可以分析出来。然而,有不少人习惯于把任何不需要的内存使用的增加描述为内存泄漏,严格意义上来说这是不准确的。 一般我们常说的内存泄漏是指堆内存的泄漏。堆内存是指程序从堆中分配的,大小任意的(内存块的大小可以在程序运行期决定),使用完后必须显式释放的内存。应用程序一般使用mallo. 阅读全文

posted @ 2013-12-06 14:06 Step-BY-Step 阅读(991) 评论(0) 推荐(0) 编辑

Chp4: Trees and Graphs

摘要: 1.Type of Tree1. Binary Tree:abinary treeis atreein which each node has at most twochild nodes(denoted as theleftchild and therightchild).Adirected edgerefers to the link from theparentto thechild(the arrows in the picture of the tree).Theroot nodeof a tree is thenodewith no parents. There is at mos 阅读全文

posted @ 2013-12-06 09:45 Step-BY-Step 阅读(481) 评论(0) 推荐(0) 编辑

trie树--详解

摘要: 文章作者:yx_th000文章来源:Cherish_yimi (http://www.cnblogs.com/cherish_yimi/) 转载请注明,谢谢合作。关键词:trie trie树 数据结构 [本文新址:http://www.ahathinking.com/archives/14.html]前几天学习了并查集和trie树,这里总结一下trie。 本文讨论一棵最简单的trie树,基于英文26个字母组成的字符串,讨论插入字符串、判断前缀是否存在、查找字符串等基本操作;至于trie树的删除单个节点实在是少见,故在此不做详解。lTrie原理Trie的核心思想是空间换时间。利用字符串的公共前. 阅读全文

posted @ 2013-12-06 09:39 Step-BY-Step 阅读(230) 评论(0) 推荐(0) 编辑

Tries

摘要: trie,又称前缀树或字典樹,是一种有序树,用于保存关联数组,其中的键通常是字符串。与二叉查找树不同,键不是直接保存在节点中,而是由节点在树中的位置决定。一个节点的所有子孙都有相同的前缀,也就是这个节点对应的字符串,而根节点对应空字符串。一般情况下,不是所有的节点都有对应的值,只有叶子节点和部分内部节点所对应的键才有相关的值。一个保存了 8 个键的 trie 结构,"A", "to", "tea", "ted", "ten", "i", "in", and 阅读全文

posted @ 2013-12-06 09:36 Step-BY-Step 阅读(271) 评论(0) 推荐(0) 编辑

Comparable & Comparator

摘要: Comparable & Comparator 都是用来实现集合中元素的比较、排序的,只是 Comparable 是在集合内部定义的方法实现的排序,Comparator 是在集合外部实现的排序,所以,如想实现排序,就需要在集合外定义 Comparator 接口的方法或在集合内实现 Comparable 接口的方法。Comparator位于包java.util下,而Comparable位于包 java.lang下Comparable 是一个对象本身就已经支持自比较所需要实现的接口(如 String、Integer 自己就可以完成比较大小操作,已经实现了Comparable接口) 自定义的 阅读全文

posted @ 2013-12-06 07:39 Step-BY-Step 阅读(195) 评论(0) 推荐(0) 编辑

memory leak

摘要: Incomputer science, amemory leakoccurs when acomputer programincorrectly managesmemory allocations.[1]Inobject-oriented programming, a memory leak may happen when anobjectis stored in memory but cannot be accessed by the running code.[2]A memory leak has symptoms similar to a number of other problem 阅读全文

posted @ 2013-12-06 07:02 Step-BY-Step 阅读(297) 评论(0) 推荐(0) 编辑

8个月从CS菜鸟到拿到Google Offer的经历+内推

摘要: http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=77453&page=1&authorid=103773投了肯定有100家以上,一共面了30家,11个onsite,前7次都挂了,后4次拿到了3家大公司和一家startup的Offer,最后从了G家。我的背景,国内软件工程混沌过了4年,毕业时连Java,C++的main都分不清,一共没写过100行代码,CS基础知识是极度零散与凌乱的。误打误撞读了CS 一年的master,12年9月入学,13年1月底开始找工作,当时的程度,和本科毕业时,没太多区别。总 阅读全文

posted @ 2013-12-06 05:37 Step-BY-Step 阅读(950) 评论(0) 推荐(0) 编辑

Word Ladder II

摘要: Given two words (startandend), and a dictionary, find all shortest transformation sequence(s) fromstarttoend, such that:Only one letter can be changed at a timeEach intermediate word must exist in the dictionaryFor example,Given:start="hit"end="cog"dict=["hot","dot 阅读全文

posted @ 2013-12-06 04:08 Step-BY-Step 阅读(211) 评论(0) 推荐(0) 编辑

Java垃圾回收机制

摘要: 转自:http://www.infoq.com/cn/articles/cf-java-garbage-references/Java的垃圾回收器要负责完成3件任务:分配内存、确保被引用的对象的内存不被错误回收以及回收不再被引用的对象的内存空间。垃圾回收是一个复杂而且耗时的操作。如果JVM花费过多的时间在垃圾回收上,则势必会影响应用的运行性能。一般情况下,当垃圾回收器在进行回收操作的时候,整个应用的执行是被暂时中止(stop-the-world)的。这是因为垃圾回收器需要更新应用中所有对象引用的实际内存地址。不同的硬件平台所能支持的垃圾回收方式也不同。比如在多CPU的平台上,就可以通过并行的方 阅读全文

posted @ 2013-12-06 02:40 Step-BY-Step 阅读(243) 评论(0) 推荐(0) 编辑

Java引用类型

摘要: 转自:http://www.infoq.com/cn/articles/cf-java-garbage-references/如果一个内存中的对象没有任何引用的话,就说明这个对象已经不再被使用了,从而可以成为被垃圾回收的候选。不过由于垃圾回收器的运行时间不确定,可被垃圾回收的对象的实际被回收时间是不确定的。对于一个对象来说,只要有引用的存在,它就会一直存在于内存中。如果这样的对象越来越多,超出了JVM中的内存总数,JVM就会抛出OutOfMemory错误。虽然垃圾回收的具体运行是由JVM来控制的,但是开发人员仍然可以在一定程度上与垃圾回收器进行交互,其目的在于更好的帮助垃圾回收器管理好应用的内 阅读全文

posted @ 2013-12-06 02:39 Step-BY-Step 阅读(264) 评论(0) 推荐(0) 编辑

Java 泛型(Generics)

摘要: Generics, 类似C++中的模版。允许在定义类和接口的时候使用类型参数(type parameters), 声明的类型参数在使用的时候用具体的类型来替换。 如 ArrayList files = new ArrayLis();可以使得程序有更好的可读性 和 安全性。1.泛型类并没有自己独有的class类对象。2.静态变量是被泛型类的所有实例共享的。3。反省的类型参数不能用在java异常处理的catch语句中。使用type parameters后,编译器会进行检查,避免插入错误类型的对象。泛型类与一般的Java类基本相同,只是在类和接口定义上多出来了用声明的类型参数。一个类可以有多个类型参 阅读全文

posted @ 2013-12-06 02:37 Step-BY-Step 阅读(346) 评论(0) 推荐(0) 编辑

2013年12月5日

位运算的巧妙应用

摘要: 位运算的符号 与运算:& 或运算:| 异或运算:^ 非运算:~ 移位运算:>>和<<判断一个数是否是2的N次方 题目要求:用一个表达式,判断一个数X是否是2的N次方,即2,4,8,16……等,要求不可以用循环语句。 解析:2,4,8,16这样的数转化成二进制是10,100,1000,10000。 如果X减去1后(低一位并且二进制的每一位都是1),这个数与X做与运算,答案若是0,则X是2的N次方。 所以答案是:!(X&(X-1))两个数的交换 题目要求:将a,b两个数的值进行交换,并且不使用任何的中间变量。解法1: a = a+b; ... 阅读全文

posted @ 2013-12-05 13:10 Step-BY-Step 阅读(134) 评论(0) 推荐(0) 编辑

Class Object

摘要: java.langClass Objectjava.lang.Objectpublic class ObjectClassObjectis the root of the class hierarchy. Every class hasObjectas a superclass. All objects, including arrays, implement the methods of this class.MethodsModifier and TypeMethod and DescriptionprotectedObjectclone()Creates and returns a co 阅读全文

posted @ 2013-12-05 13:04 Step-BY-Step 阅读(245) 评论(0) 推荐(0) 编辑

CC150 上面重要的题目总结

摘要: 第一章 :全部重要 (1.6, 1.7 Leetcode上有)。1.5 面A碰到 (string compression)1.7面Z碰到 (set 0)1.8面Bigfish碰到 (string rotation)第二章 (2.4, 2.5 Leetcode上有):全部重要。2.2面Bigfish碰到 (find kth)第三章 :感觉就是3.2 (min stack), 3.5 (two stack queue) 重要。两道题面M被问到过。3.6(sort stack)感觉也有可能被考到。第四章 (4.1, 4.3, 4.5 Leetcode上有):感觉4.2, 4.3, 4.5,4.6, 阅读全文

posted @ 2013-12-05 12:57 Step-BY-Step 阅读(1031) 评论(0) 推荐(0) 编辑

Reorder List

摘要: Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given{1,2,3,4}, reorder it to{1,4,2,3}.分析:先用快慢指针找到链表的中点,然后翻转链表后半部分,再和前半部分组合。需要注意的是把链表分成两半时,前半段的尾节点要置为NULL,翻转链表时也要把尾节点置为NULL。 1 /** 2 * Definit 阅读全文

posted @ 2013-12-05 05:22 Step-BY-Step 阅读(238) 评论(0) 推荐(0) 编辑

Sort List

摘要: Sort a linked list inO(nlogn) time using constant space complexity.nlogn的排序有快速排序、归并排序、堆排序。双向链表用快排比较适合,堆排序也可以用于链表,单向链表适合用归并排序。以下是用归并排序的代码: 1 /** 2 * Definition for singly-linked list. 3 * class ListNode { 4 * int val; 5 * ListNode next; 6 * ListNode(int x) { 7 * val = x; 8 ... 阅读全文

posted @ 2013-12-05 04:48 Step-BY-Step 阅读(314) 评论(0) 推荐(0) 编辑

Binary Search Tree In-Order Traversal Iterative Solution

摘要: Given a binary search tree, print the elements in-order iteratively without using recursion.Note:Before you attempt this problem, you might want to tr... 阅读全文

posted @ 2013-12-05 04:48 Step-BY-Step 阅读(692) 评论(0) 推荐(0) 编辑

2013年12月3日

Binary Tree Postorder Traversal

摘要: Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].No... 阅读全文

posted @ 2013-12-03 14:24 Step-BY-Step 阅读(428) 评论(0) 推荐(0) 编辑

Evaluate Reverse Polish Notation

摘要: Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another expression.Some examples: ["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9 ["4", "13&qu 阅读全文

posted @ 2013-12-03 14:18 Step-BY-Step 阅读(163) 评论(0) 推荐(0) 编辑

Data Structure Notes

该文被密码保护。 阅读全文

posted @ 2013-12-03 13:23 Step-BY-Step 阅读(2) 评论(0) 推荐(0) 编辑

2013年11月26日

Binary Tree Preorder Traversal

摘要: Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].Note:Recursive solution is trivial, could you do it iteratively?如果不能使用recursive 那么就只能使用stack来保存状态。 1 /** 2 * Definition for binary tree 3 * public clas... 阅读全文

posted @ 2013-11-26 13:05 Step-BY-Step 阅读(187) 评论(0) 推荐(0) 编辑

Linked List Cycle II

摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space? 1 public class Solution { 2 public ListNode detectCycle(ListNode head) { 3 // IMPORTANT: Please reset any member data you declared, as 4 ... 阅读全文

posted @ 2013-11-26 09:33 Step-BY-Step 阅读(134) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 9 ··· 14 下一页

导航