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.