Skip to content

Commit e5fc518

Browse files
committed
test: [20250915] Add (1935)
1 parent 10dc3b1 commit e5fc518

File tree

13 files changed

+201
-36
lines changed

13 files changed

+201
-36
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ members = [
318318
"problems/problems_3227",
319319
"problems/problems_3541",
320320
"problems/problems_966",
321+
"problems/problems_1935",
321322
]
322323

323324
[package]
@@ -658,3 +659,4 @@ solution_2785 = { path = "problems/problems_2785", features = ["solution_2785"]
658659
solution_3227 = { path = "problems/problems_3227", features = ["solution_3227"] }
659660
solution_3541 = { path = "problems/problems_3541", features = ["solution_3541"] }
660661
solution_966 = { path = "problems/problems_966", features = ["solution_966"] }
662+
solution_1935 = { path = "problems/problems_1935", features = ["solution_1935"] }

daily-problems.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"daily": "966",
2+
"daily": "1935",
33
"plans": ["3683", "problems", "3684", "problems", "3685", "problems", "3686", "problems"]
44
}

golang/solution_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package golang
22

33
import (
4-
problem "leetCode/problems/problems_966"
4+
problem "leetCode/problems/problems_1935"
55
"testing"
66
)
77

88
func TestSolution(t *testing.T) {
9-
TestEach(t, "966", "problems", problem.Solve)
9+
TestEach(t, "1935", "problems", problem.Solve)
1010
}

problems/problems_1935/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "solution_1935"
3+
version = "0.1.0"
4+
edition = "2021"
5+
rust-version = "1.79.0"
6+
authors = ["benhao"]
7+
description = "LeetCode Solution 1935 in Rust"
8+
readme = "../../README.md"
9+
10+
[features]
11+
solution_1935 = []
12+
13+
[dependencies]
14+
serde_json = "1.0"
15+
rand = "0.8.4"
16+
regex = "1.10.5"
17+
library = { path = "../../rust/library", features = ["model"] }
18+
19+
[lib]
20+
name = "solution_1935"
21+
path = "solution.rs"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//go:build ignore
2+
#include "cpp/common/Solution.h"
3+
4+
5+
using namespace std;
6+
using json = nlohmann::json;
7+
8+
class Solution {
9+
public:
10+
int canBeTypedWords(string text, string brokenLetters) {
11+
12+
}
13+
};
14+
15+
json leetcode::qubh::Solve(string input_json_values) {
16+
vector<string> inputArray;
17+
size_t pos = input_json_values.find('\n');
18+
while (pos != string::npos) {
19+
inputArray.push_back(input_json_values.substr(0, pos));
20+
input_json_values = input_json_values.substr(pos + 1);
21+
pos = input_json_values.find('\n');
22+
}
23+
inputArray.push_back(input_json_values);
24+
25+
Solution solution;
26+
string text = json::parse(inputArray.at(0));
27+
string brokenLetters = json::parse(inputArray.at(1));
28+
return solution.canBeTypedWords(text, brokenLetters);
29+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package problems.problems_1935;
2+
3+
import com.alibaba.fastjson.JSON;
4+
import java.util.*;
5+
import qubhjava.BaseSolution;
6+
7+
8+
public class Solution extends BaseSolution {
9+
public int canBeTypedWords(String text, String brokenLetters) {
10+
11+
}
12+
13+
@Override
14+
public Object solve(String[] inputJsonValues) {
15+
String text = jsonStringToString(inputJsonValues[0]);
16+
String brokenLetters = jsonStringToString(inputJsonValues[1]);
17+
return JSON.toJSON(canBeTypedWords(text, brokenLetters));
18+
}
19+
}

problems/problems_1935/problem.md

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,41 @@
11
# 1935. Maximum Number of Words You Can Type [Rating: 1226.83]
22

3-
There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly.
3+
<p>There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly.</p>
44

5-
Given a string `text` of words separated by a single space (no leading or trailing spaces) and a string `brokenLetters` of all **distinct** letter keys that are broken, return *the **number of words** in* `text` *you can fully type using this keyboard*.
5+
<p>Given a string <code>text</code> of words separated by a single space (no leading or trailing spaces) and a string <code>brokenLetters</code> of all <strong>distinct</strong> letter keys that are broken, return <em>the <strong>number of words</strong> in</em> <code>text</code> <em>you can fully type using this keyboard</em>.</p>
66

7-
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
89

9-
**Example 1:**
10+
<pre>
11+
<strong>Input:</strong> text = &quot;hello world&quot;, brokenLetters = &quot;ad&quot;
12+
<strong>Output:</strong> 1
13+
<strong>Explanation:</strong> We cannot type &quot;world&quot; because the &#39;d&#39; key is broken.
14+
</pre>
1015

11-
```
12-
Input: text = "hello world", brokenLetters = "ad"
13-
Output: 1
14-
Explanation: We cannot type "world" because the 'd' key is broken.
15-
```
16+
<p><strong class="example">Example 2:</strong></p>
1617

17-
**Example 2:**
18+
<pre>
19+
<strong>Input:</strong> text = &quot;leet code&quot;, brokenLetters = &quot;lt&quot;
20+
<strong>Output:</strong> 1
21+
<strong>Explanation:</strong> We cannot type &quot;leet&quot; because the &#39;l&#39; and &#39;t&#39; keys are broken.
22+
</pre>
1823

19-
```
20-
Input: text = "leet code", brokenLetters = "lt"
21-
Output: 1
22-
Explanation: We cannot type "leet" because the 'l' and 't' keys are broken.
23-
```
24+
<p><strong class="example">Example 3:</strong></p>
2425

25-
**Example 3:**
26+
<pre>
27+
<strong>Input:</strong> text = &quot;leet code&quot;, brokenLetters = &quot;e&quot;
28+
<strong>Output:</strong> 0
29+
<strong>Explanation:</strong> We cannot type either word because the &#39;e&#39; key is broken.
30+
</pre>
2631

27-
```
28-
Input: text = "leet code", brokenLetters = "e"
29-
Output: 0
30-
Explanation: We cannot type either word because the 'e' key is broken.
31-
```
32-
33-
34-
35-
**Constraints:**
36-
37-
- 1 <= text.length <= 10<sup>4</sup>
38-
- `0 <= brokenLetters.length <= 26`
39-
- `text` consists of words separated by a single space without any leading or trailing spaces.
40-
- Each word only consists of lowercase English letters.
41-
- `brokenLetters` consists of **distinct** lowercase English letters.
32+
<p>&nbsp;</p>
33+
<p><strong>Constraints:</strong></p>
4234

35+
<ul>
36+
<li><code>1 &lt;= text.length &lt;= 10<sup>4</sup></code></li>
37+
<li><code>0 &lt;= brokenLetters.length &lt;= 26</code></li>
38+
<li><code>text</code> consists of words separated by a single space without any leading or trailing spaces.</li>
39+
<li>Each word only consists of lowercase English letters.</li>
40+
<li><code>brokenLetters</code> consists of <strong>distinct</strong> lowercase English letters.</li>
41+
</ul>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# 1935. 可以输入的最大单词数 [难度分: 1226.83]
2+
3+
<p>键盘出现了一些故障,有些字母键无法正常工作。而键盘上所有其他键都能够正常工作。</p>
4+
5+
<p>给你一个由若干单词组成的字符串 <code>text</code> ,单词间由单个空格组成(不含前导和尾随空格);另有一个字符串 <code>brokenLetters</code> ,由所有已损坏的不同字母键组成,返回你可以使用此键盘完全输入的 <code>text</code> 中单词的数目。</p>
6+
7+
<p> </p>
8+
9+
<p><strong>示例 1:</strong></p>
10+
11+
<pre><strong>输入:</strong>text = "hello world", brokenLetters = "ad"
12+
<strong>输出:</strong>1
13+
<strong>解释:</strong>无法输入 "world" ,因为字母键 'd' 已损坏。
14+
</pre>
15+
16+
<p><strong>示例 2:</strong></p>
17+
18+
<pre><strong>输入:</strong>text = "leet code", brokenLetters = "lt"
19+
<strong>输出:</strong>1
20+
<strong>解释:</strong>无法输入 "leet" ,因为字母键 'l' 和 't' 已损坏。
21+
</pre>
22+
23+
<p><strong>示例 3:</strong></p>
24+
25+
<pre><strong>输入:</strong>text = "leet code", brokenLetters = "e"
26+
<strong>输出:</strong>0
27+
<strong>解释:</strong>无法输入任何单词,因为字母键 'e' 已损坏。
28+
</pre>
29+
30+
<p> </p>
31+
32+
<p><strong>提示:</strong></p>
33+
34+
<ul>
35+
<li><code>1 &lt;= text.length &lt;= 10<sup>4</sup></code></li>
36+
<li><code>0 &lt;= brokenLetters.length &lt;= 26</code></li>
37+
<li><code>text</code> 由若干用单个空格分隔的单词组成,且不含任何前导和尾随空格</li>
38+
<li>每个单词仅由小写英文字母组成</li>
39+
<li><code>brokenLetters</code> 由 <strong>互不相同</strong> 的小写英文字母组成</li>
40+
</ul>

problems/problems_1935/solution.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package problem1935
2+
3+
import (
4+
"encoding/json"
5+
"log"
6+
"strings"
7+
)
8+
9+
func canBeTypedWords(text string, brokenLetters string) int {
10+
11+
}
12+
13+
func Solve(inputJsonValues string) any {
14+
inputValues := strings.Split(inputJsonValues, "\n")
15+
var text string
16+
var brokenLetters string
17+
18+
if err := json.Unmarshal([]byte(inputValues[0]), &text); err != nil {
19+
log.Fatal(err)
20+
}
21+
if err := json.Unmarshal([]byte(inputValues[1]), &brokenLetters); err != nil {
22+
log.Fatal(err)
23+
}
24+
25+
return canBeTypedWords(text, brokenLetters)
26+
}

problems/problems_1935/solution.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use serde_json::{json, Value};
2+
3+
pub struct Solution;
4+
5+
impl Solution {
6+
pub fn can_be_typed_words(text: String, broken_letters: String) -> i32 {
7+
8+
}
9+
}
10+
11+
#[cfg(feature = "solution_1935")]
12+
pub fn solve(input_string: String) -> Value {
13+
let input_values: Vec<String> = input_string.split('\n').map(|x| x.to_string()).collect();
14+
let text: String = serde_json::from_str(&input_values[0]).expect("Failed to parse input");
15+
let broken_letters: String = serde_json::from_str(&input_values[1]).expect("Failed to parse input");
16+
json!(Solution::can_be_typed_words(text, broken_letters))
17+
}

0 commit comments

Comments
 (0)