Skip to content

Commit 3cf3395

Browse files
committed
feat: update
1 parent eecca4b commit 3cf3395

File tree

14 files changed

+892
-0
lines changed

14 files changed

+892
-0
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
comments: true
3+
difficulty: 中等
4+
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3324.Find%20the%20Sequence%20of%20Strings%20Appeared%20on%20the%20Screen/README.md
5+
---
6+
7+
<!-- problem:start -->
8+
9+
# [3324. 出现在屏幕上的字符串序列](https://leetcode.cn/problems/find-the-sequence-of-strings-appeared-on-the-screen)
10+
11+
[English Version](/solution/3300-3399/3324.Find%20the%20Sequence%20of%20Strings%20Appeared%20on%20the%20Screen/README_EN.md)
12+
13+
## 题目描述
14+
15+
<!-- description:start -->
16+
17+
<p>给你一个字符串 <code>target</code>。</p>
18+
19+
<p>Alice 将会使用一种特殊的键盘在她的电脑上输入 <code>target</code>,这个键盘<strong> 只有两个 </strong>按键:</p>
20+
21+
<ul>
22+
<li>按键 1:在屏幕上的字符串后追加字符 <code>'a'</code>。</li>
23+
<li>按键 2:将屏幕上字符串的 <strong>最后一个 </strong>字符更改为英文字母表中的 <strong>下一个</strong> 字符。例如,<code>'c'</code> 变为 <code>'d'</code>,<code>'z'</code> 变为 <code>'a'</code>。</li>
24+
</ul>
25+
26+
<p><strong>注意</strong>,最初屏幕上是一个<em>空</em>字符串 <code>""</code>,所以她<strong> 只能</strong> 按按键 1。</p>
27+
28+
<p>请你考虑按键次数 <strong>最少</strong> 的情况,按字符串出现顺序,返回 Alice 输入 <code>target</code> 时屏幕上出现的所有字符串列表。</p>
29+
30+
<p>&nbsp;</p>
31+
32+
<p><strong class="example">示例 1:</strong></p>
33+
34+
<div class="example-block">
35+
<p><strong>输入:</strong> <span class="example-io">target = "abc"</span></p>
36+
37+
<p><strong>输出:</strong> <span class="example-io">["a","aa","ab","aba","abb","abc"]</span></p>
38+
39+
<p><strong>解释:</strong></p>
40+
41+
<p>Alice 按键的顺序如下:</p>
42+
43+
<ul>
44+
<li>按下按键 1,屏幕上的字符串变为 <code>"a"</code>。</li>
45+
<li>按下按键 1,屏幕上的字符串变为 <code>"aa"</code>。</li>
46+
<li>按下按键 2,屏幕上的字符串变为 <code>"ab"</code>。</li>
47+
<li>按下按键 1,屏幕上的字符串变为 <code>"aba"</code>。</li>
48+
<li>按下按键 2,屏幕上的字符串变为 <code>"abb"</code>。</li>
49+
<li>按下按键 2,屏幕上的字符串变为 <code>"abc"</code>。</li>
50+
</ul>
51+
</div>
52+
53+
<p><strong class="example">示例 2:</strong></p>
54+
55+
<div class="example-block">
56+
<p><strong>输入:</strong> <span class="example-io">target = "he"</span></p>
57+
58+
<p><strong>输出:</strong> <span class="example-io">["a","b","c","d","e","f","g","h","ha","hb","hc","hd","he"]</span></p>
59+
</div>
60+
61+
<p>&nbsp;</p>
62+
63+
<p><strong>提示:</strong></p>
64+
65+
<ul>
66+
<li><code>1 &lt;= target.length &lt;= 400</code></li>
67+
<li><code>target</code> 仅由小写英文字母组成。</li>
68+
</ul>
69+
70+
<!-- description:end -->
71+
72+
## 解法
73+
74+
<!-- solution:start -->
75+
76+
### 方法一
77+
78+
<!-- tabs:start -->
79+
80+
#### Python3
81+
82+
```python
83+
84+
```
85+
86+
#### Java
87+
88+
```java
89+
90+
```
91+
92+
#### C++
93+
94+
```cpp
95+
96+
```
97+
98+
#### Go
99+
100+
```go
101+
102+
```
103+
104+
<!-- tabs:end -->
105+
106+
<!-- solution:end -->
107+
108+
<!-- problem:end -->
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
comments: true
3+
difficulty: Medium
4+
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3324.Find%20the%20Sequence%20of%20Strings%20Appeared%20on%20the%20Screen/README_EN.md
5+
---
6+
7+
<!-- problem:start -->
8+
9+
# [3324. Find the Sequence of Strings Appeared on the Screen](https://leetcode.com/problems/find-the-sequence-of-strings-appeared-on-the-screen)
10+
11+
[中文文档](/solution/3300-3399/3324.Find%20the%20Sequence%20of%20Strings%20Appeared%20on%20the%20Screen/README.md)
12+
13+
## Description
14+
15+
<!-- description:start -->
16+
17+
<p>You are given a string <code>target</code>.</p>
18+
19+
<p>Alice is going to type <code>target</code> on her computer using a special keyboard that has <strong>only two</strong> keys:</p>
20+
21+
<ul>
22+
<li>Key 1 appends the character <code>&quot;a&quot;</code> to the string on the screen.</li>
23+
<li>Key 2 changes the <strong>last</strong> character of the string on the screen to its <strong>next</strong> character in the English alphabet. For example, <code>&quot;c&quot;</code> changes to <code>&quot;d&quot;</code> and <code>&quot;z&quot;</code> changes to <code>&quot;a&quot;</code>.</li>
24+
</ul>
25+
26+
<p><strong>Note</strong> that initially there is an <em>empty</em> string <code>&quot;&quot;</code> on the screen, so she can <strong>only</strong> press key 1.</p>
27+
28+
<p>Return a list of <em>all</em> strings that appear on the screen as Alice types <code>target</code>, in the order they appear, using the <strong>minimum</strong> key presses.</p>
29+
30+
<p>&nbsp;</p>
31+
<p><strong class="example">Example 1:</strong></p>
32+
33+
<div class="example-block">
34+
<p><strong>Input:</strong> <span class="example-io">target = &quot;abc&quot;</span></p>
35+
36+
<p><strong>Output:</strong> <span class="example-io">[&quot;a&quot;,&quot;aa&quot;,&quot;ab&quot;,&quot;aba&quot;,&quot;abb&quot;,&quot;abc&quot;]</span></p>
37+
38+
<p><strong>Explanation:</strong></p>
39+
40+
<p>The sequence of key presses done by Alice are:</p>
41+
42+
<ul>
43+
<li>Press key 1, and the string on the screen becomes <code>&quot;a&quot;</code>.</li>
44+
<li>Press key 1, and the string on the screen becomes <code>&quot;aa&quot;</code>.</li>
45+
<li>Press key 2, and the string on the screen becomes <code>&quot;ab&quot;</code>.</li>
46+
<li>Press key 1, and the string on the screen becomes <code>&quot;aba&quot;</code>.</li>
47+
<li>Press key 2, and the string on the screen becomes <code>&quot;abb&quot;</code>.</li>
48+
<li>Press key 2, and the string on the screen becomes <code>&quot;abc&quot;</code>.</li>
49+
</ul>
50+
</div>
51+
52+
<p><strong class="example">Example 2:</strong></p>
53+
54+
<div class="example-block">
55+
<p><strong>Input:</strong> <span class="example-io">target = &quot;he&quot;</span></p>
56+
57+
<p><strong>Output:</strong> <span class="example-io">[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;,&quot;f&quot;,&quot;g&quot;,&quot;h&quot;,&quot;ha&quot;,&quot;hb&quot;,&quot;hc&quot;,&quot;hd&quot;,&quot;he&quot;]</span></p>
58+
</div>
59+
60+
<p>&nbsp;</p>
61+
<p><strong>Constraints:</strong></p>
62+
63+
<ul>
64+
<li><code>1 &lt;= target.length &lt;= 400</code></li>
65+
<li><code>target</code> consists only of lowercase English letters.</li>
66+
</ul>
67+
68+
<!-- description:end -->
69+
70+
## Solutions
71+
72+
<!-- solution:start -->
73+
74+
### Solution 1
75+
76+
<!-- tabs:start -->
77+
78+
#### Python3
79+
80+
```python
81+
82+
```
83+
84+
#### Java
85+
86+
```java
87+
88+
```
89+
90+
#### C++
91+
92+
```cpp
93+
94+
```
95+
96+
#### Go
97+
98+
```go
99+
100+
```
101+
102+
<!-- tabs:end -->
103+
104+
<!-- solution:end -->
105+
106+
<!-- problem:end -->
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
comments: true
3+
difficulty: 中等
4+
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3325.Count%20Substrings%20With%20K-Frequency%20Characters%20I/README.md
5+
---
6+
7+
<!-- problem:start -->
8+
9+
# [3325. 字符至少出现 K 次的子字符串 I](https://leetcode.cn/problems/count-substrings-with-k-frequency-characters-i)
10+
11+
[English Version](/solution/3300-3399/3325.Count%20Substrings%20With%20K-Frequency%20Characters%20I/README_EN.md)
12+
13+
## 题目描述
14+
15+
<!-- description:start -->
16+
17+
<p>给你一个字符串 <code>s</code> 和一个整数 <code>k</code>,在 <code>s</code> 的所有子字符串中,请你统计并返回 <strong>至少有一个 </strong>字符 <strong>至少出现</strong> <code>k</code> 次的子字符串总数。</p>
18+
19+
<p><strong>子字符串 </strong>是字符串中的一个连续、<b> 非空</b> 的字符序列。</p>
20+
21+
<p>&nbsp;</p>
22+
23+
<p><strong class="example">示例 1:</strong></p>
24+
25+
<div class="example-block">
26+
<p><strong>输入:</strong> <span class="example-io">s = "abacb", k = 2</span></p>
27+
28+
<p><strong>输出:</strong> <span class="example-io">4</span></p>
29+
30+
<p><strong>解释:</strong></p>
31+
32+
<p>符合条件的子字符串如下:</p>
33+
34+
<ul>
35+
<li><code>"aba"</code>(字符 <code>'a'</code> 出现 2 次)。</li>
36+
<li><code>"abac"</code>(字符 <code>'a'</code> 出现 2 次)。</li>
37+
<li><code>"abacb"</code>(字符 <code>'a'</code> 出现 2 次)。</li>
38+
<li><code>"bacb"</code>(字符 <code>'b'</code> 出现 2 次)。</li>
39+
</ul>
40+
</div>
41+
42+
<p><strong class="example">示例 2:</strong></p>
43+
44+
<div class="example-block">
45+
<p><strong>输入:</strong> <span class="example-io">s = "abcde", k = 1</span></p>
46+
47+
<p><strong>输出:</strong> <span class="example-io">15</span></p>
48+
49+
<p><strong>解释:</strong></p>
50+
51+
<p>所有子字符串都有效,因为每个字符至少出现一次。</p>
52+
</div>
53+
54+
<p>&nbsp;</p>
55+
56+
<p><strong>提示:</strong></p>
57+
58+
<ul>
59+
<li><code>1 &lt;= s.length &lt;= 3000</code></li>
60+
<li><code>1 &lt;= k &lt;= s.length</code></li>
61+
<li><code>s</code> 仅由小写英文字母组成。</li>
62+
</ul>
63+
64+
<!-- description:end -->
65+
66+
## 解法
67+
68+
<!-- solution:start -->
69+
70+
### 方法一
71+
72+
<!-- tabs:start -->
73+
74+
#### Python3
75+
76+
```python
77+
78+
```
79+
80+
#### Java
81+
82+
```java
83+
84+
```
85+
86+
#### C++
87+
88+
```cpp
89+
90+
```
91+
92+
#### Go
93+
94+
```go
95+
96+
```
97+
98+
<!-- tabs:end -->
99+
100+
<!-- solution:end -->
101+
102+
<!-- problem:end -->

0 commit comments

Comments
 (0)