File tree Expand file tree Collapse file tree 3 files changed +3
-37
lines changed
solution/1400-1499/1408.String Matching in an Array Expand file tree Collapse file tree 3 files changed +3
-37
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ function stringMatching(words: string[]): string[] {
138
138
const res: string [] = [];
139
139
for (const target of words ) {
140
140
for (const word of words ) {
141
- if (word = == target && word .includes (target )) {
141
+ if (word ! == target && word .includes (target )) {
142
142
res .push (target );
143
143
break ;
144
144
}
Original file line number Diff line number Diff line change @@ -129,41 +129,7 @@ function stringMatching(words: string[]): string[] {
129
129
const res: string [] = [];
130
130
for (const target of words ) {
131
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
- ```### * * TypeScript **
160
-
161
- ```ts
162
- function stringMatching (words : string []): string [] {
163
- const res : string [] = [];
164
- for (const target of words ) {
165
- for (const word of words ) {
166
- if (word == = target && word . includes (target )) {
132
+ if (word !== target && word .includes (target )) {
167
133
res .push (target );
168
134
break ;
169
135
}
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ function stringMatching(words: string[]): string[] {
2
2
const res : string [ ] = [ ] ;
3
3
for ( const target of words ) {
4
4
for ( const word of words ) {
5
- if ( word = == target && word . includes ( target ) ) {
5
+ if ( word ! == target && word . includes ( target ) ) {
6
6
res . push ( target ) ;
7
7
break ;
8
8
}
You can’t perform that action at this time.
0 commit comments