I have tried with two methods , using comments kindly , help me to know why both of the methods are not working .
How to take input into 2D vector
hello @ashsingh
for method one,
declare tmp inside while loop.
because for each iteraton of k ,u need to store answer in new vector.
for method two,
u are accessing a[i] to access vector at index i, first u need to declare ur vector as vector< vector > a(k);
Hello Aman, I tired both your suggestion but , using method 1 i am getting output as as 0 1 2 only. And for method 2 I am getting segmentation fault. Can u share the working code with me . It will great help.