Explanation inside the code.
Key functions added in the end of each question.
For question details, please go to Leetcode
-
- Easy 101 Symmetric Tree --
[re = list(reversed(li))]
- Easy 107 Binary Tree Level Order Traversal II --
[results[::-1]]
- Easy 559 Maximum Depth of N-ary Tree
- Medium 993 Cousins in Binary Tree
- Medium 515 Find Largest Value in Each Tree Row --
[float('-inf')]
- Easy 101 Symmetric Tree --
-
Iteration VS recursive.
- Pre-order traversal
- In-order traversal
- Post-order traversal
- Medium 200 Number of Islands
-
The use of collections.Counter() and dictionary.
- Easy 884 Uncommon Words from Two Sentences --
[collections.Counter()]
- Easy 387 First Unique Character in a String --
[collections.Counter()]
--[float('inf')]
--[index = string.find('c')]
- Easy 1512. Number of Good Pairs
[math.comb(n,k)]
- Medium 347 Top K Frequent Elements --
[counts = sorted(dic.values())]
- Easy 1 Two Sum --
[for i,item in enumerate(nums)]
- Medium 3 Longest Substring Without Repeating Characters
- Easy 884 Uncommon Words from Two Sentences --
-
- Medium 438 Find All Anagrams in a String
-
- Medium 2 Add Two Numbers --
[carry = carry//10]
- Medium 19 Remove Nth Node From End of List
- Easy 21 Merge Two Sorted Lists
- Medium 2 Add Two Numbers --
-
- Medium 105 Construct Binary Tree from Preorder and Inorder Traversal -- recursive
-
- Medium 763 Partition Labels