How can we access nth list of vector when we have declared just 1 list of vector Look at this sol i have initialized array of vector of size 1 and still it is working for n>1(Written in the editorial that n<=20) , how can it be possible Plz explain
I think it’s because C++ doesn’t provide bounds checking for the [] operator and if the index value exceeds the vector/array size the program exhibits undefined behavior (fortunately in your case it runs just fine ). Please refer this thread on stack overflow.