原题网址:https://www.lintcode.com/problem/flatten-binary-tree-to-linked-list/description 描述 将一棵二叉树按照前序遍历拆解成为一个假链表。所谓的假链表是说,用二叉树的 right 指针,来表示链表中的 next 指针。 ...
分类:
其他好文 时间:
2018-07-02 00:04:57
阅读次数:
111
喜欢的话可以扫码关注我们的公众号哦,更多精彩尽在微信公众号【程序猿声】 01 单链表(Singly Linked List ) 1.1 什么是单链表? 单链表是一种链式存储的结构。它动态的为节点分配存储单元。当有节点插入时,系统动态的为结点分配空间。在结点删除时,应该及时释放相应的存储单元,以防止内 ...
分类:
其他好文 时间:
2018-06-29 23:37:40
阅读次数:
373
Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 题意: 给定一个链表,判断是否有环 思路: 快慢指针 若有环,则快慢指针一定会在 ...
分类:
其他好文 时间:
2018-06-26 11:07:35
阅读次数:
185
Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1: Example 2: 题意: 有序链表去重 思路: 代码: ...
分类:
其他好文 时间:
2018-06-26 11:03:07
阅读次数:
128
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the ...
分类:
其他好文 时间:
2018-06-26 11:02:16
阅读次数:
121
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You may not modify the values in the list's nodes, only nodes its ...
分类:
其他好文 时间:
2018-06-26 10:54:26
阅读次数:
246
迭代器模式是设计模式中行为模式(behavioral pattern)的一个例子,他是一种简化对象间通讯的模式,也是一种非常容易理解和使用的模式。简单来说,迭代器模式使得你能够获取到序列中的所有元素而不用关心是其类型是array,list,linked list或者是其他什么序列结构。这一点使得能够 ...
Description Sort a linked list using insertion sort. Description Description Sort a linked list using insertion sort. Sort a linked list using inserti ...
分类:
编程语言 时间:
2018-06-16 13:31:41
阅读次数:
171
Given a binary tree, design an algorithm which creates a linked list of all the nodes at each depth.(e.g., if you have a tree with depth D, you'll hav ...
分类:
其他好文 时间:
2018-06-16 01:01:26
阅读次数:
144
Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all ...
分类:
其他好文 时间:
2018-06-13 21:06:20
阅读次数:
267