fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. #define main dummy_main
  5. int main(){
  6. return 0;
  7. }
  8. #undef main
  9. #define TreeNode dummy_Tree_node
  10. struct TreeNode{
  11. }
  12. ;
  13. #undef TreeNode
  14. class Solution{
  15. public:
  16. TreeNode* removeLeafNodes(TreeNode* root, int target){
  17. if(root == NULL){
  18. return root;
  19. }
  20. root->left = removeLeafNodes(root->left, target);
  21. root->right = removeLeafNodes(root->right, target);
  22. if(root->left==NULL && root->right==NULL && root->val==target){
  23. root = NULL;
  24. }
  25. return root;
  26. }
  27. }
  28. ;
  29. // cLay varsion 20200119-1
  30.  
  31. // --- original code ---
  32. // #define main dummy_main
  33. // {}
  34. // #undef main
  35. //
  36. // #define TreeNode dummy_Tree_node
  37. // struct TreeNode {};
  38. // #undef TreeNode
  39. //
  40. // class Solution {
  41. // public:
  42. // TreeNode* removeLeafNodes(TreeNode* root, int target) {
  43. // if(root == NULL) return root;
  44. // root->left = removeLeafNodes(root->left, target);
  45. // root->right = removeLeafNodes(root->right, target);
  46. // if(root->left==NULL && root->right==NULL && root->val==target) root = NULL;
  47. // return root;
  48. // }
  49. // };
  50.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:16:3: error: ‘TreeNode’ does not name a type; did you mean ‘remove’?
   TreeNode* removeLeafNodes(TreeNode* root, int target){
   ^~~~~~~~
   remove
stdout
Standard output is empty