Home > Back-end >  About C STL vector in the two-dimensional dynamic array
About C STL vector in the two-dimensional dynamic array

Time:11-01

The class Solution {
Public:
Vector Vec.
Vector LevelOrder (root TreeNode *) {
Level_binary (root, 0);
Return vec.
}
Void level_binary (root TreeNode * and an int level) {
If (root==NULL) {//recursive termination conditions
return ;
}
If (vec) size ()==level) vec. Resize (level + 1);
Vec [level] push_back (root - & gt; Val);
Level_binary (root - & gt; Left, level + 1);
Level_binary (root - & gt; Right, level + 1);
}
};


I want to ask why the vector of a two-dimensional array of first d: why do you want to use the resize
  • Related