Skip to content

Commit 6a7a8b8

Browse files
committed
update
1 parent 1e2349a commit 6a7a8b8

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

Python/uniqueBinarySearchTrees.py renamed to Python/unique-binary-search-trees.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ class Solution:
1717
# @return an integer
1818
def numTrees(self, n):
1919
counts = [1, 1]
20-
for i in range(2, n + 1):
20+
for i in xrange(2, n + 1):
2121
count = 0
2222
for j in xrange(i):
2323
count += counts[j] * counts[i - j - 1]
2424
counts.append(count)
2525
return counts[-1]
2626

2727
if __name__ == "__main__":
28-
print Solution().numTrees(3)
28+
print Solution().numTrees(3)

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ Problem | Solution | Time | Space | Difficul
372372
[Populating Next Right Pointers in Each Node]|[populating-next-right-pointers-in-each-node.py]| _O(n)_ | _O(logn)_ | Medium |
373373
[Same Tree] |[same-tree.py] | _O(n)_ | _O(logn)_ | Easy |
374374
[Sum Root to Leaf Numbers] | [sum-root-to-leaf-numbers.py] | _O(n)_ | _O(logn)_ | Medium |
375+
[Unique Binary Search Trees II] | [unique-binary-search-trees-ii.py] | _O(4^n / n^(3/2))_ | _O(4^n / n^(3/2))_ | Medium |
375376

376377
[Balanced Binary Tree]:https://oj.leetcode.com/problems/balanced-binary-tree/
377378
[balanced-binary-tree.py]:https://github.com/kamyu104/LeetCode/blob/master/Python/balanced-binary-tree.py
@@ -397,6 +398,8 @@ Problem | Solution | Time | Space | Difficul
397398
[same-tree.py]:https://github.com/kamyu104/LeetCode/blob/master/Python/same-tree.py
398399
[Sum Root to Leaf Numbers]:https://oj.leetcode.com/problems/sum-root-to-leaf-numbers/
399400
[sum-root-to-leaf-numbers.py]:https://github.com/kamyu104/LeetCode/blob/master/Python/sum-root-to-leaf-numbers.py
401+
[Unique Binary Search Trees II]:https://oj.leetcode.com/problems/unique-binary-search-trees-ii/
402+
[unique-binary-search-trees-ii.py]:https://github.com/kamyu104/LeetCode/blob/master/Python/unique-binary-search-trees-ii.py
400403

401404

402405
---
@@ -525,6 +528,7 @@ Problem | Solution | Time | Space | Difficul
525528
[Regular Expression Matching] | [regular-expression-matching.py] | _O(m * n)_ | _O(n)_ | Hard |
526529
[Scramble String] | [scramble-string.py] | _O(n^4)_ | _O(n^3)_ | Hard |
527530
[Triangle] | [triangle.py] | _O(m * n)_ | _O(n)_ | Medium |
531+
[Unique Binary Search Trees] | [unique-binary-search-trees.py] | _O(n^2)_ | _O(n)_ | Medium |
528532

529533
[Best Time to Buy and Sell Stock III]:https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/
530534
[best-time-to-buy-and-sell-stock-iii.py]:https://github.com/kamyu104/LeetCode/blob/master/Python/best-time-to-buy-and-sell-stock-iii.py
@@ -554,7 +558,8 @@ Problem | Solution | Time | Space | Difficul
554558
[scramble-string.py]:https://github.com/kamyu104/LeetCode/blob/master/Python/scramble-string.py
555559
[Triangle]:https://oj.leetcode.com/problems/triangle/
556560
[triangle.py]:https://github.com/kamyu104/LeetCode/blob/master/Python/triangle.py
557-
561+
[Unique Binary Search Trees]:https://oj.leetcode.com/problems/unique-binary-search-trees/
562+
[unique-binary-search-trees.py]:https://github.com/kamyu104/LeetCode/blob/master/Python/unique-binary-search-trees.py
558563

559564
---
560565

0 commit comments

Comments
 (0)