File tree 2 files changed +19
-2
lines changed
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 2
2
3
3
![ problems-solved] ( https://img.shields.io/badge/Problems%20Solved-107/571-1f425f.svg )
4
4
![ problems-solved-java] ( https://img.shields.io/badge/Java-107/1571-1abc9c.svg )
5
- ![ problems-solved-python] ( https://img.shields.io/badge/Python-30 /1571-1abc9c.svg )
5
+ ![ problems-solved-python] ( https://img.shields.io/badge/Python-31 /1571-1abc9c.svg )
6
6
[ ![ PRs Welcome] ( https://img.shields.io/badge/PRs-welcome-brightgreen.svg )] ( CONTRIBUTING.md )
7
7
8
8
## Problems
29
29
| 83 | [ Remove Duplicates from Sorted List] ( https://leetcode.com/problems/remove-duplicates-from-sorted-list ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/RemoveDuplicatesFromSortedList.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/remove_duplicates_from_linked_list.py ) |
30
30
| 88 | [ Merge Sorted Array] ( https://leetcode.com/problems/merge-sorted-array ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/MergeSortedArray.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/merge_sorted_array.py ) |
31
31
| 100 | [ Same Tree] ( https://leetcode.com/problems/same-tree ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/SameTree.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/same_tree.py ) |
32
- | 101 | [ Symmetric Tree] ( https://leetcode.com/problems/symmetric-tree ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/SymmetricTree.java ) |
32
+ | 101 | [ Symmetric Tree] ( https://leetcode.com/problems/symmetric-tree ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/SymmetricTree.java ) [ ![ Python ] ( https://img.icons8.com/color/35/000000/python.png )] ( python/symmetric_tree.py ) |
33
33
| 104 | [ Maximum Depth of Binary Tree] ( https://leetcode.com/problems/maximum-depth-of-binary-tree ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/MaximumDepthOfBinaryTree.java ) |
34
34
| 107 | [ Binary Tree Level Order Traversal II] ( https://leetcode.com/problems/binary-tree-level-order-traversal-ii ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/BinaryTreeLevelOrderTraversalII.java ) |
35
35
| 108 | [ Convert Sorted Array To Binary Search Tree] ( https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/ConvertSortedArrayToBinarySearchTree.java ) |
Original file line number Diff line number Diff line change
1
+ # Definition for a binary tree node.
2
+ class TreeNode :
3
+ def __init__ (self , val = 0 , left = None , right = None ):
4
+ self .val = val
5
+ self .left = left
6
+ self .right = right
7
+
8
+
9
+ class Solution :
10
+ def is_symmetric (self , left : TreeNode , right : TreeNode ) -> bool :
11
+ if left and right :
12
+ return left .val == right .val and self .is_symmetric (left .left , right .right ) \
13
+ and self .is_symmetric (left .right , right .left )
14
+ return left == right
15
+
16
+ def isSymmetric (self , root : TreeNode ) -> bool :
17
+ return root is None or self .is_symmetric (root .left , root .right )
You can’t perform that action at this time.
0 commit comments