上一页 1 2 3 4 5 6 ··· 17 下一页
摘要: Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space?/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: bool hasCycle... 阅读全文
posted @ 2013-11-13 10:00 懒猫欣 阅读(125) 评论(0) 推荐(0)
摘要: static 变量 头文件中的static会在引用该头文件的cpp中分别生成副本//H.h#ifndef _H_H_#define _H_H_static int a = 0;#endif//Ex_2.c#include "H.h"void fun_ex2 (){ a++; printf ("%d", a);//这时会打印1}//Ex_3#include "H.h"void fun_ex3 (){ printf ("%d", a);//这时打印的依然是0,即便先被Ex_2中的fun_ex2()函数修改过,因为他们 阅读全文
posted @ 2013-10-18 11:44 懒猫欣 阅读(152) 评论(0) 推荐(0)
摘要: windows默认使用\\linux默认使用/可以都用/ 阅读全文
posted @ 2013-10-16 10:53 懒猫欣 阅读(476) 评论(0) 推荐(0)
摘要: class A{ int a; char c; char b;};class B{ char c; int a; char b;};int main(int argc, char* argv[]){ cout<<sizeof(A)<<" "<<sizeof(B)<<endl; return 0;}输出结果为8,12class A1{};class A2{};class A3{};class A4{int a;};class A:A1,A2,A3{};class B:A4,A2,A3{};class C:A2,A4,A3{};i 阅读全文
posted @ 2013-10-14 23:20 懒猫欣 阅读(200) 评论(0) 推荐(0)
摘要: 1.给一个长为n的链表,如何只扫描链表一次从中随机算出m个数(m..< 阅读全文
posted @ 2013-10-10 14:53 懒猫欣 阅读(124) 评论(0) 推荐(0)
摘要: Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "A 阅读全文
posted @ 2013-10-09 00:16 懒猫欣 阅读(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 requirements:Each child must have at least one candy.Children with a higher rating get more candies than their neighbors.What is the minimum candies you 阅读全文
posted @ 2013-10-08 23:33 懒猫欣 阅读(366) 评论(0) 推荐(0)
摘要: Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"click to show corner cases.Corner Cases:Did you consider the case where path = "/../"?In this case, you should r 阅读全文
posted @ 2013-10-08 20:56 懒猫欣 阅读(189) 评论(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:boo 阅读全文
posted @ 2013-10-08 20:28 懒猫欣 阅读(343) 评论(0) 推荐(0)
摘要: Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region . For example,X X X XX O O XX X O XX O X XAfter running your function, the board should be:X X X XX X X 阅读全文
posted @ 2013-10-08 15:08 懒猫欣 阅读(194) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 ··· 17 下一页