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

Method traverse

99. Recover Binary Search Tree/Solution.cpp:29–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 Solution():sw1(NULL), sw2(NULL), prev(new TreeNode(1 << 31)) {}
28
29 void traverse(TreeNode * root) {
30 if (root == NULL) return ;
31 traverse(root->left);
32 // in-order traverse
33 // edge case stack overfloe
34 if (sw1 == NULL and prev->val >= root->val and root->val != (1 << 31)) sw1 = prev;
35 if (sw1 != NULL and prev->val >= root->val) sw2 = root;
36 prev = root;
37 traverse(root->right);
38 }
39
40 void swap() {
41 int tmp = sw1->val;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected