← 返回 bloomberg 的题目列表Print URLs using Data Structures
类型:online_judge
bloomberg
Design a class to store URLs. This class should support the following operations:
Add a new URL.
Delete a specified URL.
Return a random stored URL, with a time complexity of O(1).
Provide the implementation of this class and demonstrate how it can be used in various test cases. Ensure to use appropriate data structures to achieve O(1) time complexity.
Input Example:
add_url("https://www.example.com")
delete_url("https://www.example.com")
get_random_url()
Output Example:
For the inputs above, a possible output might be (output may vary based on design):
URL added
URL deleted
https://www.example.com
Data Scale:
URL length does not exceed 200 characters.
Number of operations does not exceed 10000.
Example
Input
add_url('https://www.example1.com')
delete_url('https://www.example1.com')
get_random_url()