<s> class TreeNode : <EOL> def __init__ ( self , x ) : <EOL> self . val = x <EOL> self . left = None <EOL> self . right = None <EOL> class Solution : <EOL> def minDepth ( self , root ) : <EOL> if root is None : <EOL> return <NUM_LIT:0> <EOL> if root . left and root . right : <EOL> return min ( self . minDepth ( root . left ) , self . minDepth ( root . right ) ) + <NUM_LIT:1> <EOL> else : <EOL> return max ( self . minDepth ( root . left ) , self . minDepth ( root . right ) ) + <NUM_LIT:1> <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> root = TreeNode ( <NUM_LIT:1> ) <EOL> root . left = TreeNode ( <NUM_LIT:2> ) <EOL> print Solution ( ) . minDepth ( root ) </s>
