- 博客(10)
- 资源 (1)
- 收藏
- 关注
原创 leetcode-110 Balanced Binary Tree
使用深度优先搜索(depth first search)算法遍历二叉树,有两种方式: This problem is generally believed to have two solutions: the top down approach and the bottom up way. (https://oj.leetcode.com/discuss/22898/the-bottom-
2015-02-18 10:20:26 403
原创 leetcode-58 Length of Last Word
不要调用什么split之类的函数(questions like this one is intended to be a practice of detail implementation, not calling other functions) https://oj.leetcode.com/discuss/9148/my-simple-solution-in-c 我的code,参考了
2015-02-17 16:06:24 499
原创 leetcode-165 Compare Version Numbers
注意 :1.0与1.00.00相等的,可能有third-level或者forth-levelatoi函数:如果第一个非空格字符存在,是数字或者正负号则开始做类型转换,之后检测到非数字(包括结束符 \0,比如小数点) 字符时停止转换,返回整型数。否则,返回零。例如:atoi(“123.456”),返回123;我的code如下:char *nextSubStr(char *str){ char
2015-02-17 15:29:02 377
转载 leetcode-169 Majority Element(Moore's voting algorithm)
最近在刷LeetCode的题(169 Majority Element)的时候,发现一个特别巧妙的算法:Moore’s voting algorithm。 这个算法是解决这样一个问题:从一个数组中找出出现半数以上的元素。 Moore的主页上有这个算法的介绍:A Linear Time Majority Vote Algorithm和这个算法的一个简单示例演示:演示链接。
2015-02-17 11:12:18 582
原创 leetcode-171 Excel Sheet Column Number
这题本质是个进制转换的问题(26进制转换为10进制): int titleToNumber(char *s) { int sum = 0; int i = 0; int tmp = 'A' - 1; for(; i < strlen(s); i++){ sum = sum *26 + (s[i] - tmp); } return s
2015-02-16 18:00:23 406
原创 leetcode-38 count and say
题目的意思有点迷惑,正确的理解如下: At the beginning, I got confusions about what is the nth sequence. Well, my solution is accepted now, so I'm going to give some examples of nth sequence here. The following are s
2015-02-16 16:04:09 455
原创 leetcode-20 Valid Parentheses
主要思想就是入栈出栈,用数组模拟栈,栈的大小为1024 版本1:纯自己写,未参考他人答案,比较粗糙 bool isValid(char *s) { char stack[1024]; int i = 0,j = 0; //stack[i++] = s[j++]; for(; j < strlen(s);j++){ if( (s[j] == '('
2015-02-15 15:09:15 410
转载 文件描述符 文件描述标志 文件状态标志
文件描述符 File Descriptors 文件描述标志 File Descriptors Flag 文件状态标志 File Status Flag 文件描述符是一个标示,非负整数,类似于windows里的句柄,为了与标准C保持一致(标准C里的文件的读写都是通过File Pointer)UNIX采用了这样的三级结构,我混淆于文件描述标志和文件状态标志,还是看
2015-02-15 10:17:39 1458
原创 C字符串的小问题
今天遇到这样一种写法(C语言):char * str="abc" "def"; 这样也能给字符串赋值,语法好奇怪,你们见过吗; 两个被双引号括起来的字符串,只要当中是空格(包括换行),C就认为这是一个字符串。在《C PRIMER PLUS》第四章的 Exploring and Exploiting printf() and scanf()小节中有如下引文: new with ANSI C,
2015-02-06 21:10:05 446
转载 Redis源码学习笔记(一)-- 整体运行流程详解
本文所引用的源码全部来自Redis2.8.2版本。 Redis源码整体运行流程的相关文件是:redis.h, redis.c, networking.c, ae.h, ae.c。 转载请注明,本文出自:http://blog.csdn.net/acceptedxukai/article/details/17842119 Redis Server端处理Client请求的流程
2015-02-06 20:00:58 937
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人