File tree Expand file tree Collapse file tree 4 files changed +98
-0
lines changed
solution/1400-1499/1408.String Matching in an Array Expand file tree Collapse file tree 4 files changed +98
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,42 @@ func stringMatching(words []string) []string {
131
131
}
132
132
```
133
133
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
+
134
170
### ** ...**
135
171
136
172
```
Original file line number Diff line number Diff line change @@ -122,6 +122,42 @@ func stringMatching(words []string) []string {
122
122
}
123
123
```
124
124
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
+
125
161
### ** ...**
126
162
127
163
```
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments