About the time complexity of the map and set count (personal opinion, incorrect please indicate) count in __stl

Source: Internet
Author: User
About the time complexity of the map and set count
Recently in Fuzhou OJ made a Problem 2227 stamps, with a set.count to do on time, the result of mapping directly with the map of the word over. So I suspect that the time complexity of count is not Nlogn, the final thought of the time complexity of Count should be O (nlogn+ (length of the queried value), parsed below: Because map and set are both the structure of the red-black tree, and in the second point only find the value of a position, But it just means that there is such a number, not how many times I have this number, so I think it's two minutes. In one traversal, so there will be many of the same number, the time complexity is very ugly, which is why the problem of the fzu that the issue will timeout, but this is only my guess, has not been verified, you are welcome to put forward your valuable comments, thank you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.