pydsa.combo¶
pairs ¶
pairs(
n: int, type: Maker = tuple, back: bool = False
) -> Iterator[Any]
Every (i, j) with 0 <= i < j < n, in lexicographic order.
With back, the pairs are grouped by the later index instead: for each j in turn, every (i, j) with i < j. That is the dp order, where cell j looks back at every earlier cell.
Each pair is built by type: tuple by default, list for a LeetCode answer.
Source code in pydsa/combo.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
triples ¶
triples(n: int, type: Maker = tuple) -> Iterator[Any]
Every (i, j, k) with 0 <= i < j < k < n, in lexicographic order.
Each triple is built by type: tuple by default, list for a LeetCode answer.
Source code in pydsa/combo.py
29 30 31 32 33 34 35 36 37 | |