Advertisement
vaibhav1906

inorder

Jan 4th, 2022
1,019
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     void inorder(TreeNode * root, vector<int> &ans){
  4.         if(root==NULL)return;
  5.        
  6.         inorder(root->left,ans);
  7.         ans.push_back(root->val);
  8.         inorder(root->right,ans);
  9.        
  10.         return;
  11.        
  12.     }
  13.     vector<int> inorderTraversal(TreeNode* root) {
  14.         vector<int> ans;
  15.         inorder(root, ans);
  16.        
  17.         return ans;
  18.     }
  19. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement