Lesson 10 of 24

vector: పెరిగే Array

9 min 30 XP

STL (Standard Template Library) C++ యొక్క superpower. vector పెరిగే array: push_back చేరుస్తుంది, size() లెక్కిస్తుంది, v[i] లేదా v.at(i) చదువుతుంది. Competitive programmers ప్రతిచోటా vectors వాడతారు.

Example: edit me and press Run

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.

v.at(i) bounds ను తనిఖీ చేసి exception ఇస్తుంది; v[i] తనిఖీ చేయదు కానీ వేగంగా ఉంటుంది.

Challenge

+30 XP

n మరియు n సంఖ్యలను చదివి వాటి prefix sums ను print చేయండి (ప్రతి స్థానం అప్పటి వరకు మొత్తాన్ని కలిగి ఉంటుంది). Input: 5 1 2 3 4 5 Output: 1 3 6 10 15

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.