sandeep03edu

Untitled

Jul 1st, 2022
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. // Definition for binary tree
  5. struct TreeNode {
  6.      int val;
  7.      TreeNode *left;
  8.      TreeNode *right;
  9.      TreeNode(int x) : val(x), left(NULL), right(NULL) {}
  10. };
  11.  
  12.  
  13. void changeData(TreeNode* root){
  14.     root -> val = 20;
  15. }
  16.  
  17. int lca(TreeNode* A) {
  18.     A -> val = 10;
  19.     cout<<A->val<<endl;
  20.    
  21.     changeData(A);
  22.     cout<<A->val<<endl;
  23. }
  24.  
  25. int main() {
  26.     // your code goes here
  27.     lca(new TreeNode(5));
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment