It's frustrating using python in the contest.
For problem number 1:
It should take little time finishing this problem using following code:
class Solution(object): def mergeTrees(self, t1, t2): """ :type t1: TreeNode :type t2: TreeNode :rtype: TreeNode """ if t1 is None: return t2 if t2 is None: return t1 t1.val += t2.val t1.left = self.mergeTrees(t1.left, t2.left) t1.right = self.mergeTrees(t1.right, t2.right) return t1
But there's a test case similar as follows:
for which the right answer should be [-2222222222,4,5,5,4,null,7]
But the expected answer is [2072745074,4,5,5,4,null,7] in the benchmark.
For problem number 3:
I used the same algorithm both in python and c++.
However the python code would not meet the time limit, cost me a long time to rewrite it into c++.
I actually get all the problems tackled, but due to these waste of time, I used 14 minutes longer than 90 minutes.
If following contests can consider more about the python coders, it would be better.