Menu
Coddy logo textTech

Pattern Finder

Part of the Fundamentals section of Coddy's C# journey — lesson 68 of 69.

challenge icon

Challenge

Easy

Create a program that receives two arrays of strings as input and determines if the second array appears as a pattern within the first array (in consecutive order).

A pattern exists when all elements of the second array appear together, in the same order, somewhere within the first array, like finding a substring within a string.

For example:

string str1 = {"1", "2", "3", "4", "5", "6", "7"};
string str2 = {"3", "4", "5"};
// Should return true
string str1 = {"5", "6", "7", "8", "9"};
string str2 = {"6", "8"};
// Should return false (not consecutive)

Try it yourself

using System;

public class Program {
    public static void Main(string[] args) {
        string arrString1 = Console.ReadLine();
        string arrString2 = Console.ReadLine();
        string[] str1 = arrString1.Split(",");
        string[] str2 = arrString2.Split(",");
        // Write your code below
        
    }
}

All lessons in Fundamentals