Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit be7ec05

Browse files
String Matching in an Array
1 parent 99ec2fa commit be7ec05

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Link: https://leetcode.com/problems/string-matching-in-an-array/
2+
Language: C#
3+
4+
5+
6+
7+
8+
9+
10+
public class Solution {
11+
public IList<string> StringMatching(string[] words)
12+
{
13+
List<string> result = new List<string>();
14+
15+
for (int i = 0; i < words.Length; i++)
16+
{
17+
for (int j = 0; j < words.Length; j++)
18+
{
19+
if (i != j && words[j].Contains(words[i]))
20+
{
21+
result.Add(words[i]);
22+
break;
23+
}
24+
}
25+
}
26+
27+
return result;
28+
}
29+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /