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) मर्यादा तपासते आणि 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.