摘要: 迭代 class Solution { public ListNode deleteDuplicates(ListNode head) { ListNode dummyHead = new ListNode(-1); dummyHead.next = head; ListNode cur = hea 阅读全文
posted @ 2021-10-18 15:36 振袖秋枫问红叶 阅读(34) 评论(0) 推荐(0)
摘要: 迭代 class Solution { public ListNode mergeTwoLists(ListNode list1, ListNode list2) { /** * 依次比较两个链表的节点,将较小的节点放入新的链表 */ ListNode dummyHead = new ListNod 阅读全文
posted @ 2021-10-18 15:17 振袖秋枫问红叶 阅读(39) 评论(0) 推荐(0)
摘要: 迭代 public class Algorithm { public static void main(String[] args) { int[] arr = {1, 2, 6, 3, 4, 5, 6}; ListNode head = new ListNode(arr); System.out. 阅读全文
posted @ 2021-10-18 13:36 振袖秋枫问红叶 阅读(30) 评论(0) 推荐(0)