LeetCode 53. Maximum Subarray - Python
LeetCode 53. Maximum Subarray - Python Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Follow up: If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle. Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: [4,-1,2..
2020. 9. 7.
LeetCode 101. Symmetric Tree - Python
LeetCode 101. Symmetric Tree - Python Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the following [1,2,2,null,3,null,3] is not: 1 / \ 2 2 \ \ 3 3 Solution : Recursive class Solution: def isSymmetric(self, root: TreeNode) -> bool: if not root: #루트가 없으면 True 반환..
2020. 9. 4.