Beta
Mastering The Python Standard Library #1 - Find the longest common part at the start of a list of strings
Description:
Mastering The Python Standard Library #1
Find the longest common part at the start of a list of strings
Problem
Given a list of strings, return the longest common substring that occur at the beginning of all the strings (also called the longest common prefix). If there is no such a string, return an empty string.
Example
lst = ['apple', 'application', 'appearance'] # Given a list of strings
expected_output = 'app' # The longest common prefix is 'app'
Hint
There is one function in the standard library which exactly does the same thing!
About This Series
Welcome to Mastering The Python Standard Library Series, a collection of problems designed to hone your use of the handy builtin libary!
All the problems can be readily solved by importing from the standard library! So these katas are all about how you are familiar with the builtin modules!
Strings
Fundamentals
Similar Kata:
Stats:
Created | Oct 29, 2020 |
Published | Oct 29, 2020 |
Warriors Trained | 201 |
Total Skips | 2 |
Total Code Submissions | 316 |
Total Times Completed | 101 |
Python Completions | 101 |
Total Stars | 2 |
% of votes with a positive feedback rating | 82% of 68 |
Total "Very Satisfied" Votes | 50 |
Total "Somewhat Satisfied" Votes | 11 |
Total "Not Satisfied" Votes | 7 |
Total Rank Assessments | 63 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 8 kyu |