FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GitHub Viewer

package com.leetcode; public class AddTwoNumbers { //Definition for singly-linked list //https://leetcode.com/problems/add-two-numbers/ 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 addTwoNumbers(ListNode l1, ListNode l2) { ListNode result = new ListNode();//dummy head ListNode dummy = result; int rem = 0; while(l1 != null && l2 != null){ int val = l1.val + l2.val + rem; rem = 0;//reset after add ListNode next = new ListNode(); if(val

Back | FazBrowse Home | New Git URL