Skip to content

Commit f12b675

Browse files
authored
Update probability-of-a-two-boxes-having-the-same-number-of-distinct-balls.py
1 parent 195017b commit f12b675

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Python/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ def getProbability(self, balls):
1212
"""
1313
def nCrs(n): # Time: O(n), Space: O(1)
1414
c = 1
15-
yield c
16-
for k in xrange(1, n+1):
17-
c *= n-k+1
18-
c //= k
15+
for k in xrange(n+1):
1916
yield c
17+
c *= n-(k+1)+1
18+
c //= k+1
2019

2120
def nCr(n, r): # Time: O(n), Space: O(1)
2221
if n-r < r:

0 commit comments

Comments
 (0)