Question
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
本题难度Easy。
3指针法
复杂度
时间 O(N) 空间 O(1)
思路
很简单,遇到等于val
的节点就删除,否则就跳过。
代码
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
本题难度Easy。
时间 O(N) 空间 O(1)
很简单,遇到等于val
的节点就删除,否则就跳过。
java map循环中remove
【LeetCode】39. 组合总和
LeetCode Java Remove Linked List Elements
Leetcode 203:Remove Linked List Elements[虚拟头结点]
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M