classSolution{public:
vector<int>inorderTraversal(TreeNode* root){
vector<int> result;
stack<TreeNode*> st;
TreeNode* cur = root;while(!st.empty()|| cur !=nullptr){if(cur !=nullptr){
st.push(cur);
cur = cur -> left;}else{
cur = st.top();
st.pop();
result.push_back(cur -> val);
cur = cur -> right;}}return result;}};