LeetCode OJ
Problems
Pick One!
Submissions
Discuss
Donate
Sign up
Sign in
Send Feedback
Longest Common Prefix
Total Accepted:
6189
Total Submissions:
23106
My Submissions
Write a function to find the longest common prefix string amongst an array of strings.
Discuss
C++
Java
Python
class Solution { public: string longestCommonPrefix(vector<string> &strs) { } };
public class Solution { public String longestCommonPrefix(String[] strs) { } }
class Solution: # @return a string def longestCommonPrefix(self, strs):
Submit Solution
You have not signed in, cannot submit your code.
Submit failed, try again please.
You have attempted to resubmit too soon. Please resubmit in a moment.
Send Feedback