C++ with Morris inOrder traversal 
\'\'\'\nclass Solution {\npublic:\n   \n    int inorderTraversal(TreeNode root,int L, int R){\n        int sum = 0;\n        TreeNode cur = root,pre;\n        w
\'\'\'\nclass Solution {\npublic:\n   \n    int inorderTraversal(TreeNode* root,int L, int R){\n        int sum = 0;\n        TreeNode *cur = root,*pre;\n        while(cur!=nullptr){\n            if(cur->left!=nullptr){\n                pre = cur->left;\n                while(pre->right!=nullptr && pre->right!=cur){\n                    pre = pre->right;\n                }\n                if(pre->right==nullptr){\n                    pre->right = cur;\n                    cur = cur->left;\n                }else{\n                    if(cur->val>=L && cur->val<=R)\n                        sum+=cur->val;\n                    pre->right = nullptr;\n                    cur = cur->right;\n                }\n            }else{\n                if(cur->val>=L && cur->val<=R)\n                        sum+=cur->val;\n                cur = cur->right;\n            }\n        }\n        return sum;\n    }\n    int rangeSumBST(TreeNode* root, int L, int R) {\n        if(root==nullptr)\n            return 0;\n        return inorderTraversal(root,L,R);\n    }\n};\n\'\'\'\nTime complexity: O(n)\nSpace complexity: O(1)
[]