下列代码实现的是单链表的按序插入、链表元素的删除、链表的输出// mylink.h 代码#ifndef MYLINK_H#define MYLINK_H#includeusing namespace std;struct node{ int data; node *next;}...
分类:
编程语言 时间:
2016-01-21 23:14:13
阅读次数:
191
不使用临时变量删除链表、使用临时变量删除链表typedef struct Node *PtrToNode;typedef PtrToNode List;typedef PtrToNode Position;typedef int ElementType;struct Node{ ElementT.....
分类:
其他好文 时间:
2016-01-19 12:23:48
阅读次数:
114
这里,注意如果是尾结点,那么无解。public class Solution {public void deleteNode(ListNode node) {//利用李代桃僵// // if(node.next == null)// // {// // node = null;//error: no...
分类:
其他好文 时间:
2015-12-18 00:06:32
阅读次数:
191
分成两种,1种开了额外空间,临时缓冲区,一种没有开import java.util.HashSet;import java.util.Set;class ListNode{ int data; ListNode next;}public class Solution{ public...
分类:
其他好文 时间:
2015-12-17 00:27:34
阅读次数:
156
因为这个程序快累死老子了,细节处理很麻烦package Solutions;import java.util.ArrayList;/** * Created by hu on 2015/12/12. *//** 删除链表中重复的结点*在一个排序的链表中,存在重复的结点,* 请删除该链表中重复的结点,...
分类:
其他好文 时间:
2015-12-12 14:00:29
阅读次数:
153
1、给定一个链表,删除链表中倒数第n个节点,返回链表的头节点。给出链表1->2->3->4->5->null和 n = 2.删除倒数第二个节点之后,这个链表将变成1->2->3->5->null.注意链表中的节点个数大于等于n挑战O(n)时间复杂度解题思路:刚开始看到倒数第n个节点,不禁感慨如果是数...
分类:
其他好文 时间:
2015-11-25 01:07:55
阅读次数:
211
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 is1 -> 2 -> 3 -> ...
分类:
其他好文 时间:
2015-11-14 20:35:45
阅读次数:
317
Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After re...
分类:
其他好文 时间:
2015-11-14 19:17:37
阅读次数:
282
研究了上下文缓存的实现方案,其原理类似Apache Commons Collections项目中LRUMap,它继承于AbstractLinkedMap抽象类,其基本思想是将最近使用的数据放置于链表的头上,进行LRUMap进行淘汰时只需要删除链表最后一个即可。继承关系如下图:从AbstractHas...
分类:
其他好文 时间:
2015-10-26 00:38:51
阅读次数:
442