Timeline
Timeline
2025-09-17
init
Understanding of STL containers map and set
Problem:
This problem mainly uses the idea of trading space for time. According to the given range of index and number, it can be concluded that the brute force solution will definitely TLE, and indeed it does.
Using the characteristics of set: std::set internally is a balanced binary search tree (usually a red-black tree). The smallest element in the tree is always on the leftmost side → set.begin() points to the leftmost leaf node. Therefore, rbegin() returns the maximum value.
1 |
|
