LeetCode
文章平均质量分 66
青瑟只鸟
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Valid Parentheses
很简单的一道题,以前习惯用C式C++编程,现在尝试用C++容器,感觉效率高了不少。Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.T原创 2015-04-19 22:59:16 · 725 阅读 · 0 评论 -
Reverse Linked List
Reverse a singly linked list.单链表的逆序有两种方法,一种是递归的,另一种是非递归的(头插法)。递归解法如下,耗时11ms:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(原创 2015-07-08 16:11:01 · 2093 阅读 · 1 评论 -
Sort List
Sort a linked list in O(n log n) time using constant space complexity. 一看到这个题目,首先想到归并排序。归并排序需要将数据近似划成两等分,可以用快慢指针法,慢指针一次走一步,快指针一次走两步,快指针走到链表末尾时,慢指针刚好走到一半。本题的递归解法如下:/** * Definition for sing原创 2015-07-07 22:40:04 · 681 阅读 · 0 评论 -
Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value原创 2015-07-16 14:42:46 · 845 阅读 · 0 评论
分享