- 博客(45)
- 资源 (19)
- 收藏
- 关注
原创 [LeetCode] Sort List
Sort a linked list in O(n log n) time using constant space complexity.这题思路比较直接。按照题目要求,需要在O(N*logN)时间内完成排序,所以可以考虑的排序方法只有三个:快速排序、归并排序和堆排序。然而,快速排序要求能在常数时间内置换两个指定元素,所以需要支持O(1)时间内的随机访问,这个无法在链表上实现,所以可以排
2013-11-21 12:56:34 1508
原创 [LeetCode] LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if
2013-11-12 04:35:23 8367
原创 [LeetCode] Word Ladder
Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach intermediate word m
2013-11-10 15:09:11 1270
原创 [LeetCode] Substring with Concatenation of All Words
这题一开始做了很久,尝试了先将L里的每个词的开头字符都提取出来,相同开头字符的归为一类词群,然后把L转化为了一个multimap,这样的话每次看开头字符找到可能匹配的词群所需时间就是O(1)了。之后再以S中的每个字符作为起点,开始了使用DFS逐个匹配查找。当然,最后剩的少许字符可以不用考虑,因为光剩下的子字符串的长度可能就不够覆盖L里的所有词了。这个过程很复杂的,关键是回溯的过程中,删除和恢复
2013-11-09 05:15:33 6495 5
原创 [LeetCode] Candy
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on
2013-11-09 00:51:19 2630 7
转载 HashMap、HashTable、LinkedHashMap和TreeMap用法和区别
Java为数据结构中的映射定义了一个接口java.util.Map,它有四个实现类,分别是HashMap、HashTable、LinkedHashMap和TreeMap。本节实例主要介绍这4中实例的用法和区别。关键技术剖析:Map用于存储键值对,根据键得到值,因此不允许键重复,值可以重复。l (1)HashMap是一个最常用的Map,它根据键的hashCode值存储数据,根据键可以直
2013-11-09 00:14:27 2170
原创 [LeetCode] Minimum Window Substring
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BAN
2013-11-08 14:57:49 1350
原创 [LeetCode] Palindrome Partitioning II
Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = "aab",Return
2013-11-08 12:01:18 1062
原创 [LeetCode] Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3Return 6.这
2013-11-08 00:18:45 1302
原创 [LeetCode] Interleaving String
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", ret
2013-11-07 10:31:12 1140
转载 关于二分查找的面试题归类
转自http://blog.csdn.net/walkinginthewind/article/details/8937978二分查找,最基本的算法之一,也是面试中常被考察的重点,因为基本的算法最能反映出一个人的基础是否扎实。本文对二分查找相关题目做一个总结。题目列表:1. 给定一个有序(非降序)数组A,求任意一个i使得A[i]等于target,不存在则返回-1
2013-11-06 13:09:14 2390
转载 轻松搞定面试中的链表题目
转自http://blog.csdn.net/walkinginthewind/article/details/7393134链表是最基本的数据结构,面试官也常常用链表来考察面试者的基本能力,而且链表相关的操作相对而言比较简单,也适合考察写代码的能力。链表的操作也离不开指针,指针又很容易导致出错。综合多方面的原因,链表题目在面试中占据着很重要的地位。本文对链表相关的面试题做了较
2013-11-06 13:02:33 1356
转载 轻松搞定面试中的二叉树题目
转自http://blog.csdn.net/walkinginthewind/article/details/7518888树是一种比较重要的数据结构,尤其是二叉树。二叉树是一种特殊的树,在二叉树中每个节点最多有两个子节点,一般称为左子节点和右子节点(或左孩子和右孩子),并且二叉树的子树有左右之分,其次序不能任意颠倒。二叉树是递归定义的,因此,与二叉树有关的题目基本都可以用递
2013-11-06 12:58:33 1913 1
转载 2014年计算机求职总结--准备篇 (顺便也带点自己在美国准备的总结吧)
找工作是一个长期准备的过程,突击是没什么效果的。准备时间越长,准备就越充分,就越容易拿到好的offer。我基本上从研究生一入学就一直在准备找工作的东西,看书、研究研究笔试面试题、在线编程训练、参加实习招聘等等。当然,其实主要还是研二开始准备的,也算不上多认真,反正一天一天的积累吧。这里我把我准备的内容向大家分享一下。一、推荐书籍计算机的好书挺多的,我买了也有四五十本,也花了不少钱,
2013-11-06 12:47:16 2507
原创 [LeetCode] Word Break II
Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, givens = "
2013-11-05 04:42:31 2487
转载 String, StringBuffer or StringBuilder?
String, StringBuffer Or StringBuilder? 相信大家对 String 和 StringBuffer 的区别也已经很了解了,但是估计还是会有很多同志对这两个类的工作原理有些不清楚的地方,今天我在这里重新把这个概念给大家复习一下,顺便牵出 J2SE 5.0 里面带来的一个新的字符操作的类—— StringBuilder (先别忙着扔我砖头,我还算清醒,
2013-11-05 02:16:35 1306
转载 CSDN的博客搜索功能太弱,教你怎么搜索自己博客的文章
原文地址:http://blog.csdn.net/pendle/article/details/6980120不得不说,CSDN博客的搜索功能是在太弱了。而且一直都很弱,以至于我每次想在自己博客上找自己发的文章都变得那么难。做一个搜索博客内文章的功能没有那么难吧? 还是说CSDN已经放弃了博客这一块了? 我发现我的博客排名好像靠前了,难道是CSDN的博客没落了? 既
2013-11-05 01:48:28 1735 1
原创 [LeetCode] String to Integer (atoi)
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca
2013-11-05 00:35:07 1145
原创 [LeetCode] Word Break
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet"
2013-11-04 22:53:17 1648
原创 [LeetCode] Reorder List
Given a singly linked list L: 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
2013-11-04 22:26:50 7769
转载 MySQL常用命令
第一招、mysql服务的启动和停止net stopmysqlnetstart mysql第二招、登陆mysql语法如下:mysql -u用户名 -p用户密码键入命令mysql -uroot -p,回车后提示你输入密码,输入12345,然后回车即可进入到mysql中了,mysql的提示符是:mysql>注意,如果是连接到另外的机器上,则需要加入一个参数-h机器IP第三
2013-11-04 21:03:51 915
转载 Eclispse Out Of Memory Error Solution
eclipse 有启动参数里设置jvm大小,因为eclipse运行时自己也需要jvm,所以eclipse.ini里设置的jvm大小不是具体某个程序运行时所用jvm的大小,这和具体程序运行的jvm大小无关。那么怎么才能设置某个程序的jvm大小呢(当然控制台运行的话不会存在这个问题,如:java -Xms256m -Xmx1024m classname,这样就可以把当前程序的jvm大小给设定)?
2013-11-04 21:02:06 1351
原创 OpenMP学习笔记
编译命令:gcc –O XXX.c -fopenmp1. Multi-thread Programming1. 首先要import相应的API,因此必须在首行写上#include “omp.h”。2. 对于要并行执行的部分,用#pragma omp parallel{…} 标记并行块范围。3. 在并行块里面,用int ID = omp_get
2013-11-04 20:59:14 4114 2
原创 MPI学习笔记
MPI Notes开头要注明 #include 以引入MPI函数库。 MPI_Comm_size: 进程个数MPI_Comm_rank: 进程ID,从0到size-1。 HelloWorld(MPI)#include “mpi.h”#include int main(int argc, char *argv[]){ intrank
2013-11-04 20:58:40 3253
转载 玩转MapReduce的10条建议
转自This piece is based on the talk “Practical MapReduce” that I gave at Hadoop User Group UK on April 14.1. Use an appropriate MapReduce languageThere are many languages and frameworks that
2013-11-04 20:58:06 1120
原创 SQL Syntax - how to group by interval
发现原来用SQL也可以group by interval,实现了类似SciQL里的grid grouping,虽然粒度只是1维上的grid,即interval。In postgres (where || is the string concatenation operator):select (score/10)*10 || '-' || (score/10)*10+9 a
2013-11-03 16:43:08 1088
转载 SSH Without a Password(SSH无密码登录)
主要用于建立自己使用的cluster和个人PC之间的登录。此外根据个人经验,SSH无密码登录在配置分布式系统(例如Hadoop和parallel databases)时往往都是第一个步骤。(除非配置的是单机盘,用IP地址处用localhost就可以搞定)。网上搜了集中方法,觉得这种方法是最好用的。The following steps can be used to ssh from
2013-11-03 16:34:00 1268
转载 VIM使用笔记
全部删除:按esc后,然后dG全部复制:按esc后,然后ggyG全选高亮显示:按esc后,然后ggvG或者ggVG Vi IMproved (VIM) 是 Bram Moolenaar 开发的与 UNIX 下的通用文本编辑器 vi 兼容并且更加强大的文本编辑器。它支持语法变色、正规表达式匹配与替换、插入补全、自定义键等等功能,为编辑文本尤其是编写程序提供了极大方便。VIM 可以运行
2013-11-03 16:21:00 1346
转载 leetcode难度及面试频率
转载自:LeetCode Question Difficulty Distribution(原132道) 1Two Sum25arraysort set
2013-11-03 16:08:13 7544
原创 [LeetCode] Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to
2013-11-03 15:44:37 909
原创 [LeetCode] ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I
2013-11-03 15:32:56 939
原创 [LeetCode] First Missing Positive
Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant
2013-11-03 15:27:27 807
原创 [LeetCode] Scramble String (非常规DP求解)
Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire inpu
2013-11-03 15:09:27 1390
原创 [LeetCode] Regular Expression Matching
'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input string (not partial).The function prototype should be:bool isMatch(c
2013-11-03 14:54:23 1204
原创 [LeetCode] Maximal Rectangle
这道题太难想了,比较全的总结在这里。http://hi.baidu.com/mzry1992/item/030f9740e0475ef7dc0f6cba核心是使用极大化思想,全局最大值肯定是局部最大值中的一个。这个题目让我瞬间联想到了高考数学里做的题目,类似于要求一个函数(全局)最大值,先用把该函数求导,然后等于0的时候就是取极值的时候,然后这些极大值里面必定会有一个是全局最大值。
2013-11-03 14:50:17 1189
原创 [LeetCode] Word Search
对于这种要找出所以可能解的问题,思路就两个字——回溯。1) 一开始匹配第一个字符,找到所有可能的起始点位置。2)对于每个位置,分别可以向上下左右四个方向进行深度遍历搜索。 private boolean dfs(char[][] board, String word, int i, int j, boolean[][] visited) { // check board[i
2013-11-03 14:37:44 1063
原创 [LeetCode] Simplify Path
核心思想很简单,使用一个栈在内容为“..”的时候弹出前一个元素即可。这题可以偷懒,使用一个StringTokenizer类,这样的话可以很快的形成一个过滤掉所有斜杠后的内容栈。 public String simplifyPath(String path) { Stack stack = new Stack(); StringBuffer strBuffer = new Strin
2013-11-03 14:29:36 1122
原创 [LeetCode] Clone Graph
这题和之前Copy List with Random Pointer的思路类似,都是要使用一个hash map建立原始节点和新建节点之间的映射。一开始写的算法遍历了graph两次:1) clone all the labels;2) clone all the edges.因为hash map是不能够遍历的,我就再加了个set。 // initial implementatio
2013-11-03 14:21:01 1671
转载 [leetcode] 求和问题总结(2Sum, 3Sum, 4Sum, K Sum)
前言:做过leetcode的人都知道, 里面有2sum, 3sum(closest), 4sum等问题, 这些也是面试里面经典的问题, 考察是否能够合理利用排序这个性质, 一步一步得到高效的算法. 经过总结, 本人觉得这些问题都可以使用一个通用的K sum求和问题加以概括消化, 这里我们先直接给出K Sum的问题描述和算法(递归解法), 然后将这个一般性的方法套用到具体的K, 比如leet
2013-11-03 14:07:03 16377 1
原创 Array DB 摘记
1. Array DB needs to support traditional DBMS operations, along with powerful user-defined operations, including linear algebra (presented in BLAS or LApack).BLAS:The BLAS (Basic Linear Algeb
2013-11-03 13:28:46 1218
Cracking The Coding Interview 5th Ed (高清版下卷)
2013-12-31
Cracking The Coding Interview 5th Ed (高清版上卷)
2013-12-31
elements of programming interviews
2013-12-14
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人