X

DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
Hard Accuracy: 40.53% Submissions: 17345 Points: 8

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.



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