✔[JAVA] Solution 100% Faster
Best Approach\n\nclass Solution {\n    public String greatestLetter(String s) {\n        for(char i=\'Z\'; i>=\'A\'; i--){ \n            if(s.indexOf(i)!=-1 && 
**Best Approach**\n```\nclass Solution {\n    public String greatestLetter(String s) {\n        for(char i=\'Z\'; i>=\'A\'; i--){ \n            if(s.indexOf(i)!=-1 && s.indexOf(i+32)!=-1){ return i+""; } \n        }\n        return "";\n    }\n}\n```\n**Another approach**\n```\nclass Solution {\n    public String greatestLetter(String s) {\n        int[] arr=new int[26];\n        for(int i=0; i<s.length(); i++){\n            int n=s.charAt(i);\n            if(n>96){\n                if(arr[n-97]==1 || arr[n-97]==3){ arr[n-97]=3; }\n                else{ arr[n-97]=2; }\n            }\n            else{\n                if(arr[n-65]==2 || arr[n-65]==3){ arr[n-65]=3; }\n                else{ arr[n-65]=1; }\n            }\n        }\n        String ans="";\n        for(int i=0; i<26; i++){ if(arr[i]==3){ ans=(char)(i+65)+""; } }\n        return ans;\n    }\n}\n```\n\n
['Java']