1class Solution {2 int sum = 0;34 public TreeNode bstToGst(TreeNode root) {5 if (root != null) {6 bstToGst(root.right);7 sum += root.val;8 root.val = sum;9 bstToGst(root.left);10 }11 return root;12 }13}
WPM •0 •0
ACC •0 •0
TIME •0