A problem with C++

Revision en2, by SalooP, 2017-04-22 18:04:54

Look at these submissions:

26586468

26586481

They have one different that is using:

for(int c:vec)

instead of:

for(int j=0;j<vec.sz;j++{
    int c = vec[j];
    ...
}

one get Runtime and other one is Accepted.

I think that is happen because I change the size of my vector in the "for" However the size of it will be constant after each step.

Can I anyone explain? Tnks a lot.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English SalooP 2017-04-22 22:49:58 1 Tiny change: 'size();j++{\n int' -> 'size();j++){\n int'
en3 English SalooP 2017-04-22 18:06:54 4 Tiny change: '=0;j<vec.sz;j++{\n ' -> '=0;j<vec.size();j++{\n '
en2 English SalooP 2017-04-22 18:04:54 0 (published)
en1 English SalooP 2017-04-22 18:03:35 497 Initial revision (saved to drafts)