Skip to content

第二周作业#027 #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2019
Merged

Conversation

russianalfred
Copy link
Contributor

/*

  • @lc app=leetcode id=111 lang=cpp
  • [111] Minimum Depth of Binary Tree
    /
    /
    *
  • Definition for a binary tree node.
  • struct TreeNode {
  • int val;
    
  • TreeNode *left;
    
  • TreeNode *right;
    
  • TreeNode(int x) : val(x), left(NULL), right(NULL) {}
    
  • };
    */
    class Solution
    {
    public:
    int minDepth(TreeNode *root)
    {
    if (root == NULL)
    return 0;
    int left = minDepth(root->left);
    int right = minDepth(root->right);
    return (left == 0 || right == 0) ? (left + right + 1) : min(left, right) + 1;
    }
    };

@russianalfred russianalfred changed the title Create leetcode_111_027.cpp 第二周作业#027 Jun 20, 2019
@GeekUniversity GeekUniversity merged commit 7ee5087 into algorithm002:master Jun 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants