MCPcopy Create free account
hub / github.com/Ainevsia/Leetcode-Rust / help

Method help

98. Validate Binary Search Tree/Solution.cpp:21–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19class Solution {
20public:
21 bool help(TreeNode* root, int mi, int ma, bool llimit, bool rlimit) {
22 if (root == NULL) return true;
23 if (llimit and root->val <= mi or rlimit and root->val >= ma) return false;
24 return help(root->left, mi, min(ma, root->val), llimit, true)
25 and help(root->right, max(mi, root->val), ma, true, rlimit);
26 }
27
28 bool isValidBST(TreeNode* root) {
29 int ma = ((unsigned int) ~0) >> 1;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected