Skip to content

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

Open
singhsuryansh12 wants to merge 3 commits intorachitiitr:masterfrom
singhsuryansh12:master
Open

Improved template with macro for present, cpresent and size#26
singhsuryansh12 wants to merge 3 commits intorachitiitr:masterfrom
singhsuryansh12:master

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.

1 participant