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.