DAYS
HOUR
MINS
SEC
Error
Given two linked lists that represent two large positive numbers. The task is to subtract the given two numbers represented by the linked list. Subtract the smaller from the larger one.
Example 1:
Input:
L1 = 1->0->0
L2 = 1->2
Output: 8 8
Explanation: 12 subtracted from 100
gives us 88 as result.
Your Task:
The task is to complete the function subLinkedList() which should subtract the numbers represented by the linked list and return the head of the linked list representing the result.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).
Constraints:
1 <= Length of the Linked List <= 10000
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes