Longest Common Prefix - LeetCode 14 - Coding Interview Questions

preview_player
Показать описание
---- ------

The problem is that they give you a list of strings, and they ask you return the longest common prefix, and The LCP is a substring that is common to all elements of a given List of strings.

To solve this problem there are two techniques that we can use, The first one is called the Vertical scanning algorithm, the second one is the Horizontal Scanning Algorithm.

Next, we present the solution and walk you through the code step by step, highlighting the key points and explaining the logic behind each part of the solution.

Whether you are preparing for a technical interview or just looking to improve your coding skills, this video is a great resource.

If you found this video helpful, like, subscribe, comment.
#codinginterviewquestions #leetcodedailychallenge #leetcodesolution #leetcode #leetcodequestionandanswers

---- ----

Reading The problem : (0:00)
Vertical Scanning Solution : (0:23)
Horizontal Scanning Solution : (1:31)
Vertical Code Explanation. : (2:15)
Complexity Analysis : (3:03)
Horizontal Code Explanation : (3:14)
Complexity Analysis : (3:54)
Рекомендации по теме
Комментарии
Автор

Can we use sliding window on first and last string

masteradvisor
Автор

Vertica: Start with terse / pessimistic condition, and slowly relax.
Horizontal: Start with relaxed / optimistic condition, and slowly constrain.

jupingng
Автор

i dont understand in the horizontal prefix, what if the 1st word is different,
[hello, flower, flight]
wont it return "" since h != f ?

MrSirr