Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yohey03518/49bc635dd57a5c58e2af3da51e276a8e to your computer and use it in GitHub Desktop.
Save yohey03518/49bc635dd57a5c58e2af3da51e276a8e to your computer and use it in GitHub Desktop.
LeetCode_Algorithms_2_Add_Two_Numbers_Impl2
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