Initial commit

This commit is contained in:
2022-07-26 16:15:18 +05:30
commit cef4c4dcc4
65 changed files with 1806 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
class Solution {
public String longestCommonPrefix(String[] strs) {
int len = strs.length;
if (len == 0)
return "";
if (len == 1)
return strs[0];
Arrays.sort(strs);
int end = Math.min(strs[0].length(), strs[len - 1].length());
int i = 0;
while (i < end && strs[0].charAt(i) == strs[len - 1].charAt(i))
i++;
return strs[0].substring(0, i);
}
}