
Data structure
cfanrCoder
对贡献有激情,对回报有信心!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【LeetCode】Linked List Cycle
题目 Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? 解答 首先要注意空链表不成环;不能开额外的空间,即空间复杂度是o(1),可采用“快慢指针”查检查链表是否含有环,如果在快的指针能够追上慢的指针,则有环,否原创 2014-07-07 16:44:57 · 1010 阅读 · 0 评论 -
【LeetCode】Sum Root to Leaf Numbers
题目 Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find原创 2014-07-07 16:13:41 · 975 阅读 · 0 评论 -
【LeetCode】Swap Nodes in Pairs
题目 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. Your algorithm should use only constant spac原创 2014-07-07 14:46:57 · 1025 阅读 · 0 评论 -
【LeetCode】Insertion Sort List
题目 Sort a linked list using insertion sort. 解答 链表无法像数组那样从后往前依次比较插入,只能从前往后;在链表首部添加一个哨兵可以稍微简化下代码,代码如下: /** * Definition for singly-linked list. * public class ListNode { * int val; *原创 2014-07-09 14:29:19 · 1656 阅读 · 1 评论 -
【LeetCode】Path Sum
题目 Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: Given the below binary tree原创 2014-07-08 14:29:09 · 1348 阅读 · 0 评论