leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2331.cpp (352B)


      1 class Solution {
      2   public:
      3     bool evaluateTree(TreeNode *root) {
      4         switch (root->val) {
      5         case 0:
      6         case 1: return root->val;
      7         case 2: return evaluateTree(root->left) || evaluateTree(root->right);
      8         case 3: return evaluateTree(root->left) && evaluateTree(root->right);
      9         default: return false;
     10         }
     11     }
     12 };