To solve this problem, you'll have to open it on the computer

Longest Common Prefix

Strings
easy
Score: 10

Write a function to find the longest common prefix string amongst an array of strings strs of size n.

If there is no common prefix, return a string "null".

Input Format

First Parameter: Numbern

Second Parameter: An array of strings strs of size n

Output Format

Return a string

Example 1

Input: 
3
flower flow flight
Output: 
fl

Example 2

Input: 
3
dog racecar car
Output: 
null
Explanation: There is no common prefix among the input strings.

Constraints

  • 1 <= n <= 200
  • 0 <= strs[i].length <= 200
  • strs[i] consists of only lowercase English letters.
  • Expected Time Complexity - O(n*m) where m is the length of the ans
  • Expected Space Complexity - O(1)
Submit code to see the your result here