本月博客排行
-
第1名
龙儿筝 -
第2名
lerf -
第3名
fantaxy025025 - johnsmith9th
- xiangjie88
- zysnba
年度博客排行
-
第1名
青否云后端云 -
第2名
宏天软件 -
第3名
gashero - wy_19921005
- vipbooks
- benladeng5225
- e_e
- wallimn
- javashop
- ranbuijj
- fantaxy025025
- jickcai
- gengyun12
- zw7534313
- qepwqnp
- 解宜然
- ssydxa219
- zysnba
- sam123456gz
- sichunli_030
- arpenker
- tanling8334
- gaojingsong
- kaizi1992
- xpenxpen
- 龙儿筝
- jh108020
- wiseboyloves
- ganxueyun
- xyuma
- xiangjie88
- wangchen.ily
- Jameslyy
- luxurioust
- lemonhandsome
- mengjichen
- jbosscn
- zxq_2017
- lzyfn123
- nychen2000
- forestqqqq
- wjianwei666
- ajinn
- zhanjia
- Xeden
- hanbaohong
- java-007
- 喧嚣求静
- mwhgJava
- kingwell.leng
最新文章列表
链表(JavaScript实现)
1.简介
其实在大学的时候就已经学过数据结构了,不过当时是C语言版的,如今有时间就又重新复习一遍,补一下基础,这次打算用js实现,知识点都是相同的,只不过是实现方式不同而已。 栈和队列相对比较简单,用js的Array对象的push,pop,shift,unshift就可以模拟,也是最常用的数据结构,比如要存储多个元素,用数组就十分方便。但是数组的大小是固定的,从数组的 ...
jdk链表笔记
LinkedList
LinkedList是双链表,并且有头尾指针
数据结构
public class LinkedList
extends AbstractSequentialList
implements List, Deque, Cloneable, java.io.Serializable
{
transient int size = 0;
...
Java单向链表反转
Java API中的链表是双向的,我们这里自己新建一个类代表我们的链表元素结点:
class Node {
int value;
Node next;
public Node(int i) {
setValue(i);
}
public Node() {
}
public int getValue() {
return val ...
Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
Merge k个有序链表,之前做过一道题目是merge两个有序的链表,这里我们用分治的思想,用归并排序解决。先将k个链表递归的分为两部分,直到剩下两个链表,然后将两个链表合并起来。因为有k个list,假 ...
Odd Even Linked List
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.
You should try to do it in pl ...
Reverse Linked List
Reverse a singly linked list.
反转一个单向链表,采用头插法,设定两个指针pre和tem,tem记录head的下一个元素,从head开始依次指向它前面的元素,同时pre不断后移。代码如下:
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
...
Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.
Example
Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6
Return: 1 --> 2 --> 3 --> 4 --> 5
从 ...
Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins.
For example, the following two linked lists:
A: a1 → a2
↘
...
Insertion Sort List
Sort a linked list using insertion sort.
题目的要求很简单,用插入排序来排序一个链表,不清楚插入排序的可以参考几种常见的排序算法。对于链表来说,每次都将当前待插入的节点与之前的有序序列进行比较,对于数组来讲,我们是将当前元素从后往前与有序数列比较的,这样可以保证排序是稳定的。因为链表只能从头节点开始,我们只能从头节点开始比较,因此链表的插入排序是不稳定的排序 ...
Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You must do this in-place without altering the nodes' values.
For example,
Given {1,2,3,4}, reorder it to {1,4,2, ...
Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.
Note: Do not modify the linked list.
Follow up:
Can you solve it without using extra space?
判断一个链表中是否 ...
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?
判断一个链表中是否有环存在,用快慢指针来解决,设定两个指针fast和slow都指向head,我们让fast = fast.next.next,slow = slow.next, ...