c++ - what is mean by dict -


i came through program below

firstmissingpositive(vector<int> &a) {     vector<bool> dict(a.size()+1,false);      for(int i=0;i<a.size();i++){             if(a[i]>0 && a[i]<dict.size()) dict[a[i]]=true;     }      if(a.size()==1 && a[0]!=1) return 1;     else if(a.size()==1 && a[0]==1) return 2;      int i=0;     for(i=1;i<dict.size();i++){         if(dict[i]==false) return i;     }     return i; } 

in program, not mean following line

          vector<bool> dict(a.size()+1,false); 

what dict , statement?

it's variable.

the definition of variable calls specific constructor of vector initialize specific size, , initialize elements specific value.

it's equivalent to

vector<bool> dict; dict.resize(a.size()+1,false); 

see e.g. this std::vector constructor reference more information available constructors.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -