摘要: Given an array containingndistinct numbers taken from0, 1, 2, ..., n, find the one that is missing from the array.For example,Givennums=[0, 1, 3]retur... 阅读全文
posted @ 2015-10-10 20:50 eversliver 阅读(292) 评论(0) 推荐(0) 编辑
摘要: 首先是C++提供的四种转型操作:1. const_cast:常量性的转除。2. dynamic_cast:安全的向derived class进行转型,可能会带来很高的开销3. reinterpret_cast:低级转型,例如可讲pointer转成int,不建议使用4. static_cast: 强迫... 阅读全文
posted @ 2015-10-10 16:02 eversliver 阅读(397) 评论(0) 推荐(0) 编辑
摘要: Given a collection of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Each number ... 阅读全文
posted @ 2015-10-10 14:18 eversliver 阅读(222) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or... 阅读全文
posted @ 2015-10-10 09:53 eversliver 阅读(264) 评论(0) 推荐(0) 编辑
摘要: Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeat 阅读全文
posted @ 2015-10-09 22:53 eversliver 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 首先说下标准库的swap算法:1 namespace std{2 template3 void swap(T & a, T & b)4 {5 T tmp = a;6 a = b;7 b = tmp;8 }9 }显然的,标... 阅读全文
posted @ 2015-10-09 09:46 eversliver 阅读(385) 评论(0) 推荐(0) 编辑
摘要: 首先还是下面这个class;class Rational{public: Rational(int numirator = 0, int denominator = 1); int numurator() const; int denominator() ... 阅读全文
posted @ 2015-10-09 09:35 eversliver 阅读(349) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?判断一个链表是否为回文链表,有很多方法都可以进行判断,可以先遍历链表然后... 阅读全文
posted @ 2015-10-08 20:48 eversliver 阅读(296) 评论(0) 推荐(0) 编辑
摘要: Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a p 阅读全文
posted @ 2015-10-08 19:52 eversliver 阅读(236) 评论(0) 推荐(0) 编辑
摘要: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 给定一个整数,将他转换到罗马字符。同样这里的罗马字符不会超过1000(M),PS:关 阅读全文
posted @ 2015-10-08 16:14 eversliver 阅读(280) 评论(0) 推荐(0) 编辑