0431-0440

431. Encode N-ary Tree to Binary Tree $\star\star\star$

432. All O`one Data Structure $\star\star\star$

433. Minimum Genetic Mutation $\star\star$

434. Number of Segments in a String $\star$

435. Non-overlapping Intervals $\star\star$

436. Find Right Interval $\star\star$

437. Path Sum III $\star$

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
class Solution {
 public:
  int pathSum(TreeNode* root, int sum) {
    if (!root) return 0;

    return helper(root, sum) +
           pathSum(root->left, sum) +
           pathSum(root->right, sum);
  }

 private:
  int helper(TreeNode* root, int sum) {
    if (!root) return 0;

    return (sum == root->val) +
           helper(root->left, sum - root->val) +
           helper(root->right, sum - root->val);
  }
};

438. Find All Anagrams in a String $\star\star$

439. Ternary Expression Parser $\star\star$

440. K-th Smallest in Lexicographical Order $\star\star\star$