题目描述
链接地址
解法题目描述Find the nth to last element of a singly linked list. The minimum number of nodes in list is n.
ExampleGiven a List 3->2->1->5->null and n = 2, return node whose value is 1.链接地址http...
分类:
其他好文 时间:
2015-07-06 21:45:46
阅读次数:
122
动态规划: 1 class Solution { 2 public: 3 /** 4 * @param s: A string 5 * @param p: A string includes "?" and "*" 6 * @return: A boolean...
分类:
其他好文 时间:
2015-07-06 14:07:37
阅读次数:
135
问题描述Ugly number is a number that only have factors 3, 5 and 7.Design an algorithm to find the Kth ugly number. The first 5 ugly numbers are 3, 5, 7, 9, 15 …问题分析这个题,有多种方法求解,常见的是有辅助数据结构,比如priority_queue,...
分类:
其他好文 时间:
2015-07-06 01:32:42
阅读次数:
533
题目描述
链接地址
解法1
解法2题目描述ExampleFor linked list 1->2->3, the reversed linked list is 3->2->1链接地址http://www.lintcode.com/en/problem/reverse-linked-list/解法1 ListNode *reverse(ListNode *head) {
// wri...
分类:
其他好文 时间:
2015-07-06 01:30:25
阅读次数:
148
1 class Solution { 2 public: 3 /** 4 * @param s: A string 5 * @param p: A string includes "." and "*" 6 * @return: A boolean 7 ...
分类:
其他好文 时间:
2015-07-06 01:18:01
阅读次数:
338
1 class Solution { 2 public: 3 /** 4 * @param A: An integer array. 5 * @param B: An integer array. 6 * @return: a double whose for...
分类:
编程语言 时间:
2015-07-04 00:41:07
阅读次数:
143
字符串查找(又称查找子字符串),是字符串操作中一个很有用的函数。你的任务是实现这个函数。
对于一个给定的 source 字符串和一个 target 字符串,你应该在 source 字符串中找出 target 字符串出现的第一个位置(从0开始)。
如果不存在,则返回 -1。
样例
如果 source = "source" 和
target = "target",返回 -1...
分类:
其他好文 时间:
2015-07-01 18:27:21
阅读次数:
178
前序:
class Solution {
public:
/**
* @param root: The root of binary tree.
* @return: Preorder in vector which contains node values.
*/
vector preorderTraversal(TreeNode *root) {...
分类:
其他好文 时间:
2015-07-01 16:06:10
阅读次数:
173
样例
如把31转换为14,需要改变2个bit位。
(31)10=(11111)2
(14)10=(01110)2
贴代码
class Solution {
public:
/**
*@param a, b: Two integer
*return: An integer
*/
int bitSwapRequired(int a, int ...
分类:
其他好文 时间:
2015-07-01 16:01:16
阅读次数:
266
1 class Solution { 2 public: 3 /* 4 * @param n: An integer 5 * @return: True or false 6 */ 7 bool checkPowerOf2(int n) { 8 ...
分类:
其他好文 时间:
2015-07-01 08:33:17
阅读次数:
348