Delete Leaves With a Given Value Medium

Feb 02, 2020

第63天。

水题。

今天的题目是Delete Leaves With a Given Value Medium:

太水了,不解释了。

TreeNode* removeLeafNodes(TreeNode* root, int target) {
	if (root == nullptr) return nullptr;
	root->left = removeLeafNodes(root->left, target);
	root->right = removeLeafNodes(root->right, target);
	if (!root->left && !root->right && target == root->val)
		return nullptr;
	else 
		return root;
}
LeetCodeLeetCode

LeetCode Stack Tag 总结

Deepest Leaves Sum

comments powered by Disqus