diff --git a/Easy/NextGreaterElement.cpp b/Easy/NextGreaterElement.cpp new file mode 100644 index 0000000..f559787 --- /dev/null +++ b/Easy/NextGreaterElement.cpp @@ -0,0 +1,31 @@ +//he next greater element of some element x in an array is the first greater element that is to the right of x in the same array + +#include +using namespace std +class Solution { +public: + vector nextGreaterElement(vector& nums1, vector& nums2) { + vector ans; + + for(int i =0; ival<=min || root->val>=max)return false; + return helper(root->left,min,root->val)&&helper(root->right,root->val,max); + + } + bool isValidBST(TreeNode* root) { + return helper(root,LONG_MIN,LONG_MAX); + + } + +}; \ No newline at end of file