LeetCode OJ
Problems
Pick One!
Submissions
Sign up
Sign in
Longest Common Prefix
AC Rate: 708/2435
My Submissions
Write a function to find the longest common prefix string amongst an array of strings.
C++
Java
class Solution { public: string longestCommonPrefix(vector<string> &strs) { // Note: The Solution object is instantiated only once and is reused by each test case. } };
public class Solution { public String longestCommonPrefix(String[] strs) { // Note: The Solution object is instantiated only once and is reused by each test case. } }
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