30. Substring with Concatenation of All Words

This commit is contained in:
2026-03-25 23:58:01 +03:00
parent 6b483ea6d1
commit 4681660c8c
5 changed files with 80 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
var sol = new Solution();
var cases = new (string s, string[] words, int[] expected)[]
{
// ("barfoothefoobarman", new[] { "foo", "bar" }, new[] { 0, 9 }),
// ("wordgoodgoodgoodbestword", new[] { "word", "good", "best", "word" }, Array.Empty<int>()),
// ("barfoofoobarthefoobarman", new[] { "bar", "foo", "the" }, new[] { 6, 9, 12 }),
("wordgoodgoodgoodbestword", new[] { "word", "good", "best", "good" }, new[] { 8 })
};
string Format(IEnumerable<int> values) => $"[{string.Join(",", values)}]";
string FormatWords(IEnumerable<string> values) => $"[{string.Join(",", values)}]";
foreach (var (s, words, expected) in cases)
{
var actual = sol.FindSubstring(s, words);
Console.WriteLine($"{s} | {FormatWords(words)} -> {Format(actual)} (expected: {Format(expected)})");
}