Pablo Miralles

Hi! I'm a Mathematics and Computer Science student at University of Murcia, and here I talk about productivity, learning and technology

LeetCode June Challenge

Problem: LeetCode June Challenge - Day 1 Ideas: 1. The problem is really simple, you just need to swap left and right for every node, as a tree is inverted iff every subtree is inverted. Solution: class Solution { public: TreeNode* invertTree(TreeNode* root) { if(root == NULL) return NULL; invertTree(root->left); invertTree(root->right); swap(root->left, root->right); return root; } }; Problem: LeetCode June Challenge - Day 2 Ideas: 1. Since you are at the tail, you can copy the next node in the current one, and delete the next one.