韓先超K8S+DevOps云原生全棧技術:基于世界500強的高薪實戰(zhàn)Kubernetes課程
class Solution {
? ?public TreeNode addOneRow(TreeNode root, int val, int depth) {
? ? ? ?if (root == null) return null;
? ? ? ?if (depth == 1) return new TreeNode(val, root, null);
? ? ? ?
? ? ? ?if (depth == 2) {
? ? ? ? ? ?root.left = new TreeNode(val, root.left, null);
? ? ? ? ? ?root.right = new TreeNode(val, null, root.right);
? ? ? ?} else {
? ? ? ? ? ?addOneRow(root.left, val, depth - 1);
? ? ? ? ? ?addOneRow(root.right, val, depth - 1);
? ? ? ?}
? ? ? ?return root;
? ?}
標簽: