上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 34 下一页
摘要: Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.Example 1:Given intervals[1,3],[6,9], insert and merge[2,5]in as[1,5],[6,9].Example 2:Given[1,2],[3,5],[6,7],[8 阅读全文
posted @ 2013-12-20 14:37 七年之后 阅读(249) 评论(0) 推荐(0) 编辑
摘要: 如果在shell脚本中处理数据文件,那么我们就必须熟悉正则表达式。正则表达式是用来过滤数据流中文本的模式模板,模式由标准文本字符和特殊字符组成。正则表达式用特殊字符来匹配一系列一个或多个字符,要想掌握正则表达式,必须深刻认识每个特殊字符: .*^${}+?|()下面分别解释一下: 脱字符 ^ 定义从数据流中文本行的行首开始的字符; 美元符 $ 指明数据必须以该文本模式结尾; 点字符 . 用来匹配任意单字符,除了换行符; 字符组 [Yy] 用来匹配字符组中某个字符(比如y,但不清楚其大小写)出现在数据流中; 排除字符组 [^ch] 用来排除字符组中出现过字符(比如ch)的文本; 区间 [0-.. 阅读全文
posted @ 2013-12-19 20:08 七年之后 阅读(161) 评论(0) 推荐(0) 编辑
摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to reach the last index in the minimum number of jumps.For example:Given array A =[2,3,1,1,4]The minimum n 阅读全文
posted @ 2013-12-19 14:50 七年之后 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you are able to reach the last index.For example:A =[2,3,1,1,4], returntrue.A =[3,2,1,0,4], returnfalse.cl 阅读全文
posted @ 2013-12-19 14:11 七年之后 阅读(175) 评论(0) 推荐(0) 编辑
摘要: Implement wildcard pattern matching with support for'?'and'*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover the entire input string (not partial).The function prototype should be:bool i 阅读全文
posted @ 2013-12-19 11:47 七年之后 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 一.sed编辑器 shell脚本最常见的用途就是处理文本文件,sed和gawk能够极大的简化需要进行的数据处理任务。sed编辑器是流编辑器,跟普通交互式文本编辑器(如vim)不同。流编辑器在编辑器处理数据前基于预先提供的一组规则来编辑数据流。由于命令都是一行一行顺序处理,sed编辑器必须一次就完成对... 阅读全文
posted @ 2013-12-18 21:05 七年之后 阅读(719) 评论(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 problem statement to be ambiguous. You should gather all requirements up front before implementin 阅读全文
posted @ 2013-12-18 15:48 七年之后 阅读(321) 评论(0) 推荐(0) 编辑
摘要: Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.思考:大数相乘,模拟算数运算。class Solution {public: string multiply(string num1, string num2) { if(num1=="0"||num2=="0") return "0&qu 阅读全文
posted @ 2013-12-18 14:56 七年之后 阅读(175) 评论(0) 推荐(0) 编辑
摘要: Given a number represented as an array of digits, plus one to the number.思考:大数相加的思想。flag是进位标记。class Solution {public: vector plusOne(vector &digits) { int len=digits.size(); bool flag=false; digits[len-1]+=1; int i=len-1; if(digits[i]>9) flag=true; while(... 阅读全文
posted @ 2013-12-16 14:10 七年之后 阅读(219) 评论(0) 推荐(0) 编辑
摘要: Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100".思考:大数相加的思想。class Solution {public: string addBinary(string a, string b) { if(a.length()==0) return b; if(b.length()==0) return a; int len=a.length()0;i--) { ... 阅读全文
posted @ 2013-12-16 13:35 七年之后 阅读(203) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 34 下一页