Only C++ STL syntax you should know for competitive programming ,Part 1

Hello Everyone,

This tutorial is for programmers who are new to competitive programming or who are not using c++ because it seems difficult.In this tutorial i will be only demonstrating some syntax.

Vectors (Arrays Alternative)

Vectors are very similar to array only they are dynamic in nature.

i. Initialisation - It can be initialised in mainly two ways.

(ii) Access- It can be accessed as same as arrays.

(iii) Insert and remove

Suppose you have not defined the size of your vector.So in this case you will use a function named push_back() which will insert element at the end of the vector.

pop_back() will remove the element from last from the vector.

Increase the range of data types

In C++ programmers who are new to platforms like codechef and codeforces do not look at the range of constraints given in the problem and they get wrong answers.If range of your answer is more 10*8(10 to the power 7) int will only only return garbage value.

Instead use long long int (now you are good for range upto 2*63).

C++ is not that difficult if you are worried about the syntax.It will always give you advantage over python programmers in terms of speed.At initial level you have to know only minimum syntax.

In the next part ,we will learn what is unordered_set and unordered_map how to use them.

computer science student,loves to read a person’s programming experience

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