✅☑ 95% Beats || [C || Python3] || 100% Working 🔥🔥 || Please Upvote If Find useful 🔥||
PYTHON3\n\n\n\nC\n\n\n\n\npython3 []\n# Definition for singly-linked list.\n# class ListNode:\n#     def __init__(self, val=0, next=None):\n#         self.val =
PYTHON3\n\n![Screenshot (397).png](https://assets.leetcode.com/users/images/936d9de2-429e-4682-80f0-b2eef54ec37c_1708432360.5913792.png)\n\nC\n\n![Screenshot (399).png](https://assets.leetcode.com/users/images/fafba516-9af2-4239-97b2-d637a52ce928_1708432396.8626053.png)\n\n\n```python3 []\n# Definition for singly-linked list.\n# class ListNode:\n#     def __init__(self, val=0, next=None):\n#         self.val = val\n#         self.next = next\nclass Solution:\n    def mergeNodes(self, head: Optional[ListNode]) -> Optional[ListNode]:\n        main = head\n        itr1 = head\n        summ = 0\n        while itr1.next:\n            if itr1.val == 0 and itr1 != head:\n                summ += itr1.val\n                main.val = summ\n                main = main.next\n                summ = 0\n            summ += itr1.val\n            itr1 = itr1.next\n        \n        main.val = summ\n        main.next = None\n        return head\n```\n```C []\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     struct ListNode *next;\n * };\n */\nstruct ListNode* mergeNodes(struct ListNode* head) {\n    struct ListNode *main = head;\n    struct ListNode *itr1 = head;\n    int summ = 0;\n    while (itr1->next != NULL){\n        if (itr1->val == 0 && itr1 != head){\n            summ += itr1->val;\n            main->val = summ;\n            main = main->next;\n            summ = 0;\n        }\n        summ += itr1->val;\n        itr1 = itr1->next;\n    }\n    main->val = summ;\n    main->next = NULL;\n    return head;\n}\n```\n
['Linked List', 'C', 'Python3']