04 2014 档案

摘要:Work Break IGiven 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... 阅读全文
posted @ 2014-04-29 23:25 linyx 阅读(458) 评论(0) 推荐(0)
摘要:听X Japan这么久,几位大叔还是没有认清,真是惭愧。X-Japan是日本著名的视觉系摇滚乐队。原来叫X,在1992年8月HEATH入团的同时改名为X JAPAN。乐队成立于1982年1月,1989年成为日本最红的乐队。1997年4月因主唱TOSHI以音乐取向不同的理由退出,在无法找到后继主音的情... 阅读全文
posted @ 2014-04-29 22:11 linyx 阅读(863) 评论(1) 推荐(0)
摘要: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... 阅读全文
posted @ 2014-04-27 00:27 linyx 阅读(185) 评论(0) 推荐(0)
摘要: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 req... 阅读全文
posted @ 2014-04-26 17:39 linyx 阅读(168) 评论(0) 推荐(0)
摘要:假设数据是这样子的:2 104 208 3016 4032 5064 60128 70256 80512 901024 100gnuplot脚本如下: 1 set terminal postscript eps color enhanced... 阅读全文
posted @ 2014-04-24 14:28 linyx 阅读(4066) 评论(0) 推荐(1)
摘要:1. 在tex文件中加入:1 \bibliographystyle{plain} %这是格式2 \bibliography{reffile} % reffile.bib是reference的文件2. .bib文件包含引用的文章,可以直接通过google scholar导入,但是只能单条单条地导入,貌... 阅读全文
posted @ 2014-04-23 15:51 linyx 阅读(475) 评论(1) 推荐(0)
摘要:不小心把选项卡(标签页、多tab)整没了。搜了一下:在工具栏点击右键可以发现配置。 阅读全文
posted @ 2014-04-23 11:37 linyx 阅读(676) 评论(0) 推荐(0)
摘要: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 ... 阅读全文
posted @ 2014-04-15 15:55 linyx 阅读(187) 评论(0) 推荐(0)
摘要:奋是基础,一切的前提奋之上是忍耐大部分时候大部分人的“习惯”都是跟“效率”作对的奋让你有机会去跟这些习惯做斗争在 ACM 竞赛的级别,写代码不是在解题,而是实现早已在脑子里准备好的一个逻辑流程。这个追求跟大部分没有训练过的人的习惯相反,要扭转这种习惯,第一步可以做尝试有:1. 把准备和敲键盘分割为两... 阅读全文
posted @ 2014-04-15 01:02 linyx 阅读(240) 评论(0) 推荐(0)
摘要:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representatio... 阅读全文
posted @ 2014-04-14 16:36 linyx 阅读(174) 评论(0) 推荐(0)
摘要:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ... 阅读全文
posted @ 2014-04-14 14:46 linyx 阅读(179) 评论(0) 推荐(0)
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.top-down还是o(nlgn)。自己没有细想,不过查了一下,发现还是有o(n)... 阅读全文
posted @ 2014-04-14 12:00 linyx 阅读(209) 评论(0) 推荐(0)
摘要:求子串当然最经典的就是KMP算法了。brute force算法在leetcode上貌似也有一些技巧。brute force: 1 char* StrStr(const char *str, const char *target) { 2 if (!*target) return str; 3 ... 阅读全文
posted @ 2014-04-13 23:36 linyx 阅读(396) 评论(0) 推荐(0)
摘要:Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].这里主要注意的是STL的... 阅读全文
posted @ 2014-04-13 22:40 linyx 阅读(166) 评论(0) 推荐(0)
摘要:GDB调试不能打印stl容器内容,下载此文件,将之保存为~/.gdbinit就可以使用打印命令了。打印list用plist命令,打印vector用pvector,依此类推。(gdb) pvector curelem[0]: $5 = 3elem[1]: $6 = 9Vector size = 2Vector capacity = 2Element type = std::allocator::pointer 阅读全文
posted @ 2014-04-12 15:37 linyx 阅读(877) 评论(0) 推荐(0)
摘要:Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.Method I解决思路和求最短不减子序列类似:开一个数组lines,第k个位置存放的是有k个点的直线,由... 阅读全文
posted @ 2014-04-11 16:45 linyx 阅读(212) 评论(0) 推荐(0)
摘要:这个题相当经典。很多题目都可以等价过来。一、简单的O(n^2)的算法 很容易想到用动态规划做。设lis[]用于保存第1~i元素元素中最长不下降序列的长度,则lis[i]=max(lis[j])+1,且num[i]>num[j],i>j。然后在lis[]中找到最大的一个值,时间复杂度是O(n^2)。int Longest_Increasing(int num[],int n){ int lis[n],i,j; for(i=0;inum[j]&&lis[j]+1>lis[i]) lis[i]=lis[j]+1; } int ma... 阅读全文
posted @ 2014-04-10 15:04 linyx 阅读(462) 评论(0) 推荐(0)
摘要:The algorithm for evaluating any postfix expression is fairly straightforward:While there are input tokens leftRead the next token from input.If the t... 阅读全文
posted @ 2014-04-10 14:17 linyx 阅读(193) 评论(0) 推荐(0)
摘要:Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:Only one letter can be ch... 阅读全文
posted @ 2014-04-10 12:23 linyx 阅读(358) 评论(0) 推荐(0)
摘要:Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the p... 阅读全文
posted @ 2014-04-10 11:34 linyx 阅读(199) 评论(0) 推荐(0)
摘要:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.Did you use extra space?A straight forward solution using... 阅读全文
posted @ 2014-04-09 14:38 linyx 阅读(193) 评论(0) 推荐(0)
摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted fr... 阅读全文
posted @ 2014-04-09 11:54 linyx 阅读(208) 评论(0) 推荐(0)
摘要:A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any p... 阅读全文
posted @ 2014-04-08 19:10 linyx 阅读(151) 评论(0) 推荐(0)
摘要:(1) 全排列:将数组看为一个集合,将集合分为两部分:0~s和s~e,其中0~s表示已经选出来的元素,而s~e表示还没有选择的元素。perm(set, s, e){顺序从s~e中选出一个元素与s交换(即选出一个元素)调用perm(set, s + 1, e)直到s>e,即剩余集合已经为空了,输出se... 阅读全文
posted @ 2014-04-08 14:48 linyx 阅读(249) 评论(0) 推荐(0)
摘要:Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]. 1 vector > permute(vector &num) { 2 vector > result; 3 if (num.size() == 0) return result; 4 5 std::sort(num.begi... 阅读全文
posted @ 2014-04-07 14:37 linyx 阅读(129) 评论(0) 推荐(0)
摘要:并查集(Disjoint set或者Union-find set)是一种简单的用途广泛的算法和数据结构。并查集是若干个不相交集合,能够实现较快的合并和判断元素所在集合的操作,应用很多,如其求无向图的连通分量个数等。并查集可以方便地进行以下三种操作:1、Make_Set(x) 把每一个元素初始化为一个... 阅读全文
posted @ 2014-04-01 14:34 linyx 阅读(326) 评论(0) 推荐(0)