码迷,mamicode.com
首页 >  
搜索关键字:head    ( 28286个结果
《Head First 设计模式》之策略模式
策略模式(Strategy Pattern):定义了算法族,分别封装起来,让它们之间可以互相替换,此模式让算法的变化独立于使用算法的客户。 设计原则 1.找出应用中可能需要变化之处,把它们独立出来,不要和那些不需要变化的代码混在一起。 2.针对接口编辑,而不是针对实现编程。 3.多用组合,少用继承。...
分类:其他好文   时间:2014-06-12 14:22:35    阅读次数:292
[Leetcode] Merge k Sorted Lists
Question: Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.Solution: Find the smallest list-head first....
分类:其他好文   时间:2014-06-10 19:51:30    阅读次数:278
【leetcode】sort list
问题:对链表进行排序,要求时间复杂度为NlogN。归并排序。 inline ListNode* getMidle(ListNode *head){ if(NULL == head || NULL == head->next) return head; ListNode *pslow = head; ListNode *pfast = head; while (pfast->next...
分类:其他好文   时间:2014-06-10 17:35:56    阅读次数:282
【leetcode】reverse Nodes in k-groups
问题: 给定一个链表的头指针,以及一个整数k,要求将链表按每k个为一组,组内进行链表逆置。少于k个的部分不做处理。 分析: 个人觉得问题的重点是熟悉链表的就地逆置操作,就是头插法。其他的考察点如果还有的话,就的细心程度。 实现: void reverseList(ListNode *&pre, ListNode *head) { ListNode *tail = NULL; w...
分类:其他好文   时间:2014-06-10 17:25:45    阅读次数:305
【leetcode】Linked List Cycle
问题: 给定个单链表,判断该链表是否存在环。 分析: 这个问题是见的非常多的题目,问题本身而言,技巧性很强,或者说思路很巧妙,这里要说的不是这个题目本身,而是说这种技巧,在很多的地方是用的到的,比如,在寻找单链表的中间节点的时候,就可以用这种形式,一个走两步,一个走一步的形式,来获得中间节点。 // bool hasCycle(ListNode *head) { if(...
分类:其他好文   时间:2014-06-10 10:48:49    阅读次数:176
【leetcode】Convert Sorted List to Binary Search Tree
问题: 给定一个有序链表,生成对应的平衡二叉搜索树。 分析 见Convert Sorted Array to Binary Search Tree 实现: TreeNode *buildTree(ListNode* head, ListNode *end){ if(head == NULL || head == end) return NULL; ...
分类:其他好文   时间:2014-06-10 07:17:29    阅读次数:264
Plus One
题目 Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. 方法 ...
分类:其他好文   时间:2014-06-10 06:12:06    阅读次数:285
求单链表的中间节点,用快慢指针
Node* findMid(Node* &head){ if(head == NULL||head->next == NULL) return head; Node* p = head; Node* q = head; while(q->next->ne...
分类:其他好文   时间:2014-06-09 17:55:34    阅读次数:204
逆序单链表
#include using namespace std;struct Node{ Node *next; int elem;};void creatList(Node* &head){ head = new Node; int elem; cin>>elem; ...
分类:其他好文   时间:2014-06-09 17:50:43    阅读次数:219
xhtml
当单个文件需要特别样式时,就可以使用内部样式表。可以在 head 部分通过
分类:Web程序   时间:2014-06-09 13:58:23    阅读次数:261
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!