Created
June 21, 2017 16:38
-
-
Save yohey03518/49bc635dd57a5c58e2af3da51e276a8e to your computer and use it in GitHub Desktop.
LeetCode_Algorithms_2_Add_Two_Numbers_Impl2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ListNode AddTwoNumbers(ListNode l1, ListNode l2) | |
{ | |
int result = l1.val + l2.val; | |
if(result >= 10) | |
{ | |
return new ListNode(result % 10) | |
{ | |
next = new ListNode(result / 10) | |
}; | |
} | |
else | |
{ | |
return new ListNode(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment