-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path158.py
More file actions
18 lines (16 loc) · 664 Bytes
/
158.py
File metadata and controls
18 lines (16 loc) · 664 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from functools import lru_cache
alphabet_len = 26
from math import comb
def count_strings(size: int) -> int:
# We choose size characters from the alphabet
# Once chosen, each character set can have the increasing char pair
# at any position from 1 to the end
# For each increasing position i, we can pick any i-1 elements to proceed it
# but after this we must have i is the max of the remaining chars
# and all following chars in distinct sorted order
return comb(26, size) * sum(comb(size, i-1) for i in range(1, size))
assert count_strings(3) == 10400
res = 0
for i in range(1, 27):
res = max(res, count_strings(i))
print(res)