Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved template with macro for present, cpresent and size #26

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

singhsuryansh12
Copy link

I read about these macros in this TopCoder Article and found them to be really useful. Many times we encounter situations where we need to check whether an element is present in the container or not.

sz(a) finds the number of elements in container a.
present(c,x) macro uses the find member function of maps and sets works in O(logN) time.
cpresent(c,x) macro uses the global find algorithm (valid for all containers) and works in O(N) time.

Regards,
A follower of @rachitiitr 's Youtube Channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant