← 返回 stripe 的题目列表Email Subscription
类型:online_judge
Implement an email subscription management system. Users can subscribe to different topics and set notification schedules. When a subscription is about to expire, the system should send reminders based on the user's notification schedule.
Specifications:
Design the function subscribe(user_id, topic_id, expiry_date, schedule), where schedule is a string representing the reminder time, such as "1 day before".
Design the function send_schedule() to check all users' subscriptions and send reminders.
Consider the scenario where a user might have multiple subscriptions close to expiry, and handle this in send_schedule().
Input Format:
subscribe: user ID, topic ID, expiration date, notification schedule.
send_schedule: no input.
Output Format:
subscribe: no return.
send_schedule: outputs all sent notification details.
Constraints:
Each user can subscribe to a maximum of 100 topics.
Time complexity should be based on O(n) for scalability.
Example
Input
subscribe('user1', 'topic1', '2025-12-10', '1 day before')
subscribe('user1', 'topic2', '2025-12-09', '3 days before')
send_schedule()