Skip to content

Commit 2525345

Browse files
committed
Feb 18
1 parent 523da54 commit 2525345

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution:
2+
def smallestNumber(self, pattern: str) -> str:
3+
n = len(pattern)
4+
result, stack = [], []
5+
for idx in range(n+1):
6+
stack.append(str(idx+1))
7+
if idx == n or pattern[idx] == 'I':
8+
while stack:
9+
result.append(stack.pop())
10+
return ''.join(result)
11+
12+
13+
def main():
14+
pattern = 'IIIDIDDD'
15+
assert Solution().smallestNumber(pattern) == '123549876'
16+
17+
pattern = 'DDD'
18+
assert Solution().smallestNumber(pattern) == '4321'
19+
20+
21+
if __name__ == '__main__':
22+
main()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
| February 15 | [2698. Find the Punishment Number of an Integer](https://leetcode.com/problems/find-the-punishment-number-of-an-integer/) | Medium | Solved |
2222
| February 16 | [1718. Construct the Lexicographically Largest Valid Sequence](https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence/) | Medium | Unsolved |
2323
| February 17 | [1079. Letter Tile Possibilities](https://leetcode.com/problems/letter-tile-possibilities/) | Medium | Solved |
24-
| February 18 | []() | | |
24+
| February 18 | [2375. Construct Smallest Number From DI String](https://leetcode.com/problems/construct-smallest-number-from-di-string/) | Medium | Unsolved |
2525
| February 19 | []() | | |
2626
| February 20 | []() | | |
2727
| February 21 | []() | | |
@@ -38,5 +38,5 @@
3838
| Level | Problems | Solved | Unsolved |
3939
| --- | --- | --- | --- |
4040
| Easy | 6 | 6 | 0 |
41-
| Medium | 10 | 9 | 1 |
41+
| Medium | 11 | 9 | 2 |
4242
| Hard | 0 | 0 | 0 |

0 commit comments

Comments
 (0)