https://leetcode.com/problems/minimum-depth-of-binary-tree/

func minDepth(_ root: TreeNode?) -> Int {
    guard let root = root else { return 0 }
    let l = minDepth(root.left)
    let r = minDepth(root.right)
    return 1 + ((l > 0 && r > 0) ? min(l, r) : max(l, r))
}

Runtime: 36 ms, faster than 100.00% of Swift online submissions for Minimum Depth of Binary Tree.
Memory Usage: 19.7 MB, less than 33.33% of Swift online submissions for Minimum Depth of Binary Tree.