摘要: 这道题面试的时候经常遇到,特此收录。全部代码来自《剑指offer》。template class CQueue{public: CQueue(void); ~CQueue(void); void appendTail(const T &node); T deleteHe... 阅读全文
posted @ 2015-04-19 15:48 Sawyer Ford 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 结构定义: 1. 头插法创建链表 ListNode* createListFromHead() { ListNode *list = new ListNode; list->next = NULL; ListNode *s; int x; while (cin >> x) { s = new Lis 阅读全文
posted @ 2015-04-10 20:12 Sawyer Ford 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 2. base64编码 来源:http://www.ruanyifeng.com/blog/2008/06/base64.html 3. EOF 4. 地理空间距离计算优化 5. c++读取一行输入 阅读全文
posted @ 2015-04-09 20:53 Sawyer Ford 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 题目描述:请设计一个函数可以把10进制的正整数转换为4位定长的36进制字符串。36进制的规则为:“0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ”;举例说明:1=“0001”10=“000A”20=“000K”35=“000Z”36=“0010”100=“002S”2000... 阅读全文
posted @ 2015-04-07 18:49 Sawyer Ford 阅读(447) 评论(0) 推荐(0) 编辑
摘要: 题目1 : Magic Box时间限制:10000ms单点时限:1000ms内存限制:256MB描述The circus clown Sunny has a magic box. When the circus is performing, Sunny puts some balls into th... 阅读全文
posted @ 2015-04-03 22:20 Sawyer Ford 阅读(649) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 写一个函数,输入一个二叉树,树中每个节点存放了一个整数值,函数返回这棵二叉树中相差最大的两个节点间的差值绝对值。请注意程序效率。 solution: 阅读全文
posted @ 2015-04-01 21:51 Sawyer Ford 阅读(423) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.You... 阅读全文
posted @ 2015-03-24 20:54 Sawyer Ford 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity. 因为之前做过Merge Two Sorted Lists,所以这道题也就显得不那么难了。sol... 阅读全文
posted @ 2015-03-23 19:18 Sawyer Ford 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 直接... 阅读全文
posted @ 2015-03-23 15:14 Sawyer Ford 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set i... 阅读全文
posted @ 2015-03-20 21:56 Sawyer Ford 阅读(173) 评论(0) 推荐(0) 编辑