RJ Trujillo d9b9bbd4f5 leetcode: Address readability of a few cases, and fix 283
The for loop utilized in 283 was improperly structured as 'start'
was no declared as the value to index.

Also, make the other cases more readable.

Signed-off-by: RJ Trujillo <certifiedblyndguy@gmail.com>
2019-10-04 17:24:30 -06:00

10 lines
338 B
C

int rangeSumBST(struct TreeNode* root, int L, int R){
if (root == NULL) {
return 0;
} else if (root->val >= L && root->val <= R) {
return root->val + rangeSumBST(root->left, L, R) + rangeSumBST(root->right, L, R);
} else {
return rangeSumBST(root->left, L, R) + rangeSumBST(root->right, L, R);
}
}