Merge Two Sorted Lists - Definition for singly-linked list...

  • No School
  • AA 1
  • 1

This preview shows page 1 out of 1 page.

/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) { this.val = val; this.next = next; } * } */ class Solution { public ListNode mergeTwoLists(ListNode l1, ListNode l2) { ListNode dummy = new ListNode(0); ListNode current = dummy; while(l1 != null && l2 != null) {
Image of page 1

You've reached the end of your free preview.

Want to read the whole page?

  • Fall '19
  • Pointer, Copy editing, public class ListNode

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes