@@ -0,0 +1,1064 @@
+package arrays;%0A%0Aimport java.util.Arrays;%0A%0A// Given a set of strings, find the longest common prefix.%0A// Stings can't have digits or special characters.%0Apublic class LongestPrefix %7B%0A    public static void main(String%5B%5D args) %7B%0A        String%5B%5D arr = %7B%22geeksforgeeks%22, %22geeks%22, %22geek%22, %22geezer%22%7D;%0A        System.out.println(%22Longest prifox: %22 + findLongestPrefix(arr));%0A    %7D%0A%0A    private static String findLongestPrefix(String%5B%5D arr) %7B%0A        StringBuffer sb = new StringBuffer();%0A%0A        if (arr.length == 0) sb.append(%22Empty array.%22);%0A        if (arr.length == 1) sb.append(arr%5B0%5D);%0A%0A        // Sort array. The shortest string will be the first.%0A        Arrays.sort(arr);%0A%0A        // Walk all arrays starting at position arr%5B0%5D.length - 1. Compare chars. Once different, the longest%0A        // prefix is found.%0A%0A        int pos = arr%5B0%5D.length() - 1;%0A%0A        for (int i = 0; i %3C arr.length; i++) %7B%0A            if (arr%5Bi%5D.charAt(pos) != arr%5Bi + 1%5D.charAt(pos)) %7B%0A                break;%0A            %7D%0A        %7D%0A%0A        return arr%5B0%5D.substring(0, pos);%0A    %7D%0A%7D%0A

Create LongestPrefix.java