Skip to content

Commit 523da54

Browse files
committed
Feb 17
1 parent ae5c48d commit 523da54

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class Solution:
2+
def numTilePossibilities(self, tiles: str) -> int:
3+
result = set()
4+
5+
def dfs(sequence: str, remaining: str) -> None:
6+
nonlocal result
7+
if sequence in result:
8+
return
9+
result.add(sequence)
10+
for i in range(len(remaining)):
11+
dfs(sequence+remaining[i], remaining[:i]+remaining[i+1:])
12+
dfs(str(), tiles)
13+
return len(result) - 1
14+
15+
16+
def main():
17+
tiles = 'AAB'
18+
assert Solution().numTilePossibilities(tiles) == 8
19+
20+
tiles = 'AAABBC'
21+
assert Solution().numTilePossibilities(tiles) == 188
22+
23+
tiles = 'V'
24+
assert Solution().numTilePossibilities(tiles) == 1
25+
26+
27+
if __name__ == '__main__':
28+
main()

2025-02-February-LeetCoding-Challenge/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
| February 13 | [3066. Minimum Operations to Exceed Threshold Value II](https://leetcode.com/problems/minimum-operations-to-exceed-threshold-value-ii/) | Medium | Solved |
2020
| February 14 | [1352. Product of the Last K Numbers](https://leetcode.com/problems/product-of-the-last-k-numbers/) | Medium | Solved |
2121
| February 15 | [2698. Find the Punishment Number of an Integer](https://leetcode.com/problems/find-the-punishment-number-of-an-integer/) | Medium | Solved |
22-
| February 16 | []() | | |
23-
| February 17 | []() | | |
22+
| February 16 | [1718. Construct the Lexicographically Largest Valid Sequence](https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence/) | Medium | Unsolved |
23+
| February 17 | [1079. Letter Tile Possibilities](https://leetcode.com/problems/letter-tile-possibilities/) | Medium | Solved |
2424
| February 18 | []() | | |
2525
| February 19 | []() | | |
2626
| February 20 | []() | | |
@@ -38,5 +38,5 @@
3838
| Level | Problems | Solved | Unsolved |
3939
| --- | --- | --- | --- |
4040
| Easy | 6 | 6 | 0 |
41-
| Medium | 8 | 8 | 0 |
41+
| Medium | 10 | 9 | 1 |
4242
| Hard | 0 | 0 | 0 |

0 commit comments

Comments
 (0)