【leetcode 1】LinkList and Queue and Stack

一、LinkList

1.1 how to find the middle node of a linked list

1.2 用快慢指针判定一个linklist是否有环

1.3 Insert a node in a sorted linked list(simple)

Becareful about two corner cases: head and tail

1.4 How to merge two sorted linked list into one long sorted list

why or when should we use a dummy node?
When we want to append new elements to an initially empty linkedList.
we do not have an initial head node. in this case, we can new a dummy node to act as a head node.

1.5

N1->N2->N3 ->…->Nn
(N1->Nn)->(N2->Nn-1) - >…
Solution:
Step1: Find the middle node of the LinkedList
Step2: reverse the 2nd half
Step3: Merge two linkedList into one long linkedList

1.6 Partition List

Give a linked list and a target value x, partition it such that all nodes less than x are listed before the nodes larger than or equal to target value x. (keep the original relative order of the nodes in each of the two partitions.)

For example:
Input: 1->6->3->2>5 x = 4
Output: 1->3->2->6->5

Solution:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值