/**
* Definition for singly-linked list.
* public class ListNode {
* public int val;
* public ListNode next;
* public ListNode(int val=0, ListNode next=null) {
* this.val = val;
* this.next = next;
* }
*/
public class Solution {
public ListNode MergeNodes(ListNode head) {
var x = head;
while (x.next != null)
{
while (x.next.val != 0)
x.val += x.next.val;
x.next = x.next.next;
}
x = x.next;
return head;