Design a CreditTracker class with three methods:
(
-
add_credit(start_time, end_time, credit),
(
-
subtract_credit(time, credit), and
(
-
check_credit(time). When subtracting credit at a given time, always deduct from the credit that has the earliest expiration time first. The calls to add_credit and subtract_credit may arrive in arbitrary (non-monotonic) time order. Implement these methods and choose data structures that make the operations efficient; explain your approach and analyze time and space complexity.