Quick Refresh — Competitive Coding (C++)

Part II

Now that we have familiarized with the basics, let’s leap into couple of use cases and examples. Here’s how I’ve setup the show.

All set! now the first not so much of a container pair, whose main intention is to group two items. you can make a array out of it, or even better.. ‘pair’ it along with vectors as we see next..

As they say DDoS is better than Dos, we are pretty much limited with just a pair, so let’s see how an army of pairs look like.. introducing Vectors.

These operations on vectors happen at O(1) which we competitive programmers love to hear, unless you’re copying one which becomes O(n). Point to mention here is that we are free to create a much complex datastructure. However, in most use cases, they aren’t required…
Simplicity is the key.

Now that we know how to add elements at the end, a curious individual would want to insert an element in between.. as so we have Iterators.

Similar to pointers, these point to the elements of a container, defined as

NOTE:
- These are just a fraction of what iterators do, and every container has its own iterator with other functions.
- The auto keyword, introduced in C++11, dynamically sets the type of the variable, hence not requiring us to type the spells.

Up next, we’ll be looking into Sets, Maps, different types of it and so on..

-See you in Part III

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aswin Prasad

Full Stack Developer — experiments with frontend and backend made me one | love playing and modding games | Curious, Logical and Imaginative.