链表 链表分为几种类型: 单链表 public class ListNode{ int val; ListNode next; public ListNode() { } public ListNode(int val) { this.val = val; } public ListNode(int val, ListNode next) { this.val = val; this.next = next; } } 双链表 循环链表 存储方式 在内存中不是连续分布的,而是散乱分布在内存中的某地址上。 方法1:迭代 分析头节点即为需要删除元素 删除头节点后,判断链表是否为空 不为空,则利用一个临时指针来遍历链表,删除元素 class Solution { public ListNode removeElements(ListNode head, int val) { while (head != null && head.val == val){ head = head.next; } if (head == null) return head; ListNode cur =...
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile