Hi,

my solution is just the normal one, can someone tell me why time complexity is O(1) not O(n)?

```
class BSTIterator {
public:
BSTIterator(TreeNode *root) {
p=root;
}
/** @return whether we have a next smallest number */
bool hasNext() {
if(p!=NULL || !s.empty()) return true;
}
/** @return the next smallest number */
int next() {
while(p){
s.push(p);
p=p->left;
}
TreeNode* next=s.top(); s.pop();
p=next->right;
return next->val;
}
private:
stack<TreeNode*> s;
TreeNode* p;
};
```