Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
  • Loading branch information
mzusin committed Jun 9, 2024
1 parent 37d5d25 commit 8cfde16
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/combinatorics/combinatorics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ export const permutationsWithoutRepetition = (n: number, r: number) => {
* Tabulation (Bottom-Up Dynamic Programming).
* Time Complexity: 𝑂(n × r)
* Space Complexity: 𝑂(n × r)
*
* When r = 2:
* n! / (2! * (n - 2)!) = (n * (n-1) * (n - 2)!) / (2! * (n - 2)!) = n * (n-1) / 2
*/
export const combinationsWithoutRepetition = (n: number, r: number) : number => {
if (n < 0 || r < 0) {
Expand Down

0 comments on commit 8cfde16

Please sign in to comment.