Lesson 10 of 24

vector: வளரும் Arrayvector: The Growable Array

9 min 30 XP

STL (Standard Template Library) C++-ன் மிகப்பெரிய பலம். vector தானாக வளரும் array: push_back சேர்க்கும், size() எண்ணிக்கை, v[i] அல்லது v.at(i) அணுகும். Competitive programming-ல் எல்லா இடத்திலும் vector!

The STL (Standard Template Library) is C++'s superpower. A vector is an array that grows: push_back adds, size() counts, v[i] or v.at(i) reads. Competitive programmers use vectors everywhere.

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] சோதிக்காது, வேகமானது.

v.at(i) checks bounds and throws an exception; v[i] doesn't check but is faster.

Challenge

+30 XP

n மற்றும் n எண்களைப் படித்து, ஒவ்வொரு எண்ணும் அதுவரையிலான கூட்டுத்தொகையாக மாறும் prefix sum vector-ஐ print செய்யுங்கள். Input: 5 1 2 3 4 5 Output: 1 3 6 10 15

Read n and n numbers and print their prefix sums (each position holds the running total). 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.