using System;
/*
Write a function to find the longest common prefix string amongst an array of strings.
If there is no common prefix, return an empty string "".
Example 1:
Input: ["flower","flow","flight"]
Output: "fl"
Example 2:
Input: ["dog","racecar","car"]
Output: ""
Explanation: There is no common prefix among the input strings.
Note:
All given inputs are in lowercase letters a-z.
*/
public class Program
{
public static void Main()
Naive approach would be
- convert string to char array
- Have a map between letter to index in the string
- Scan thru each letter in the first word
- check if the same letter is present in other words(words can have same letters in multiple locations, so process all locations at the
the same.. as long any one of location satisfy that word is good)
- if present add the next char and repeat the proces
- once word not found, start with the second char of the first word
Console.WriteLine("Hello World");
}