Skip to content

Commit 149a18a

Browse files
committed
feat: add solutions to lc problem: No.1408
No.1408.String Matching in an Array
1 parent 5e4d84a commit 149a18a

File tree

4 files changed

+98
-0
lines changed

4 files changed

+98
-0
lines changed

solution/1400-1499/1408.String Matching in an Array/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,42 @@ func stringMatching(words []string) []string {
131131
}
132132
```
133133

134+
### **TypeScript**
135+
136+
```ts
137+
function stringMatching(words: string[]): string[] {
138+
const res: string[] = [];
139+
for (const target of words) {
140+
for (const word of words) {
141+
if (word !== target && word.includes(target)) {
142+
res.push(target);
143+
break;
144+
}
145+
}
146+
}
147+
return res;
148+
}
149+
```
150+
151+
### **Rust**
152+
153+
```rust
154+
impl Solution {
155+
pub fn string_matching(words: Vec<String>) -> Vec<String> {
156+
let mut res = Vec::new();
157+
for target in words.iter() {
158+
for word in words.iter() {
159+
if word != target && word.contains(target) {
160+
res.push(target.clone());
161+
break;
162+
}
163+
}
164+
}
165+
res
166+
}
167+
}
168+
```
169+
134170
### **...**
135171

136172
```

solution/1400-1499/1408.String Matching in an Array/README_EN.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,42 @@ func stringMatching(words []string) []string {
122122
}
123123
```
124124

125+
### **TypeScript**
126+
127+
```ts
128+
function stringMatching(words: string[]): string[] {
129+
const res: string[] = [];
130+
for (const target of words) {
131+
for (const word of words) {
132+
if (word !== target && word.includes(target)) {
133+
res.push(target);
134+
break;
135+
}
136+
}
137+
}
138+
return res;
139+
}
140+
```
141+
142+
### **Rust**
143+
144+
```rust
145+
impl Solution {
146+
pub fn string_matching(words: Vec<String>) -> Vec<String> {
147+
let mut res = Vec::new();
148+
for target in words.iter() {
149+
for word in words.iter() {
150+
if word != target && word.contains(target) {
151+
res.push(target.clone());
152+
break;
153+
}
154+
}
155+
}
156+
res
157+
}
158+
}
159+
```
160+
125161
### **...**
126162

127163
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
impl Solution {
2+
pub fn string_matching(words: Vec<String>) -> Vec<String> {
3+
let mut res = Vec::new();
4+
for target in words.iter() {
5+
for word in words.iter() {
6+
if word != target && word.contains(target) {
7+
res.push(target.clone());
8+
break;
9+
}
10+
}
11+
}
12+
res
13+
}
14+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function stringMatching(words: string[]): string[] {
2+
const res: string[] = [];
3+
for (const target of words) {
4+
for (const word of words) {
5+
if (word !== target && word.includes(target)) {
6+
res.push(target);
7+
break;
8+
}
9+
}
10+
}
11+
return res;
12+
}

0 commit comments

Comments
 (0)