Home

C# Find First Index LeetCode

One of the easiest of the easy LeetCode problems.

public class Program
{
    //https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/
    static void Main()
    {
        while (true)
        {
            Console.WriteLine("Enter Haystack");
            string haystack = Console.ReadLine();
            Console.WriteLine("Enter Needle");
            string needle = Console.ReadLine();

            Console.WriteLine(StrStr(haystack, needle));
        }
    }

    public static int StrStr(string haystack, string needle)
    {
        return haystack.IndexOf(needle);
    }
}

Reader's Comments

Post Your Comment Posts/Links Rules

Name

Comment

Add a RELEVANT link (not required)

Upload an image (not required)

No uploaded image
Real person number
Please enter the above number below




Home
Admin Ren's Biking Blog