Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!
if (condition) {
statement
}
This may mean that if root equals to null then return.if (root==null)
return;
This may mean that TreeNode right = root.right; which means that root.right will have whatever value root.right has.TreeNode right = root.right;
flatten(root.left);
This looks that root.right is being assigned the root.left value then root.left is being set to null.root.right = root.left;
root.left = null;
This appears to be while root.right is NOT null root equals to root.right value, and flatten is right and root.right is also right.while(root.right!=null){ root = root.right;
flatten(right);
root.right = right;}
flatten {
if (root==null)
return;
TreeNode right = root.right;
flatten(root.left);
root.right = root.left;
root.left = null;
while(root.right!=null) {
root = root.right;
flatten(right);
root.right = right;
}
Sorry im not firm with Java@Tealk You guys know what this means?
Code Forum is a community platform where coding enthusiasts can connect with other developers, engage in discussions, ask for help, and share their knowledge with a supportive community. It's a perfect place to improve your coding skills and to find a community of like-minded individuals who share your passion for coding.
We use essential cookies to make this site work, and optional cookies to enhance your experience.