```
class Solution {
public:
int minDepth(TreeNode *root) {
vector< TreeNode* > curLevel;
int sum = 0;
if(root == NULL){
return sum;
}
curLevel.push_back(root);
while(true){
sum++;
for( int x = curLevel.size()-1 ; x != -1; x--){
if( curLevel[x]->left == NULL && curLevel[x]->right == NULL ){
return sum;
}else{
if(curLevel[x]->right){
curLevel.push_back(curLevel[x]->right);
}
if(curLevel[x]->left){
curLevel[x] = curLevel[x]->left;
}else{
curLevel.erase(curLevel.begin()+x);
}
}
}
}
}
};
```