随笔分类 -  小程序

摘要:#define max(a, b) ((a) > (b) ? (a) : (b)) static char* reverse(char *str) { char *l, *r, c; for (l = str, r = str + strlen(str) - 1; l < r; l++, r--) { c = *l; *l = *r; ... 阅读全文
posted @ 2016-04-01 11:45 brayden 阅读(311) 评论(0) 推荐(0)
摘要:假设有一个字符串数组,每一个字符都是一个数字(1-9),找到其中的最大递增数,递增数是指相邻的数位从小到大排列的数字,如:28953456323,递增数有:289,3456,23,那么最大的递增数为3456。 阅读全文
posted @ 2016-03-31 23:32 brayden 阅读(280) 评论(0) 推荐(0)
摘要:链表检测环 链表是否交叉 两个链表第一个公共节点 阅读全文
posted @ 2016-03-31 00:03 brayden 阅读(189) 评论(0) 推荐(0)
摘要:输入“I am a student”输出“student a am I” 阅读全文
posted @ 2016-03-24 17:32 brayden 阅读(348) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/same-tree/ 阅读全文
posted @ 2016-03-22 11:31 brayden 阅读(143) 评论(0) 推荐(0)
摘要:查找某给定值在排序二叉树中是否存在. 阅读全文
posted @ 2016-03-21 13:31 brayden 阅读(669) 评论(0) 推荐(0)
摘要:/* * Zip a string. For example, "aaabcc" => "3ab2c". * You should directly update the input string. */ void strzip(char *str) { int count; char *p, *idx, c; for (count = 0, p = idx = str... 阅读全文
posted @ 2016-03-21 13:18 brayden 阅读(476) 评论(0) 推荐(0)
摘要:Leetcode上 majority element这题是 有 时间O(N), 空间O(1)的解的. https://leetcode.com/problems/majority-element/ 用hash table来解则为 时间O(N), 空间O(N). 如果是Java里 用HashMap很方 阅读全文
posted @ 2016-03-01 23:23 brayden 阅读(271) 评论(0) 推荐(0)