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
Name
Comment
Add a RELEVANT link (not required)
Upload an image (not required)
Uploading...
Home