• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
September 23, 2023 |880 Views
SDE Sheet - Longest Common Prefix
  Share   Like
Description
Discussion

This video is part of Strings section under GFG SDE Sheet.

In this video, we are give, an array of N strings, find the longest common prefix among all strings present in the array.


Example :

Input:
N = 4
arr[] = {geeksforgeeks, geeks, geek,
        geezer}
Output: gee

Explanation: "gee" is the longest common prefix in all the given strings.

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-

Article: https://www.geeksforgeeks.org/longest-common-prefix-using-word-by-word-matching/
Problem: https://practice.geeksforgeeks.org/problems/longest-common-prefix-in-an-array5129/1

Read More