We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
here is another one loop java solution:
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String s = scan.nextLine();
int[] a = new int[26];
int counter = 0;
for (int i = 0; i < s.length(); i++) {
char c = Character.toLowerCase(s.charAt(i));
int index = c - 'a';
if(index >=0 && index < 26) {
if (a[index] == 0) {
a[index] = 1;
counter++;
}
}
}
Pangrams
You are viewing a single comment's thread. Return to all comments →
here is another one loop java solution: public static void main(String[] args) { Scanner scan = new Scanner(System.in); String s = scan.nextLine(); int[] a = new int[26]; int counter = 0; for (int i = 0; i < s.length(); i++) { char c = Character.toLowerCase(s.charAt(i)); int index = c - 'a'; if(index >=0 && index < 26) { if (a[index] == 0) { a[index] = 1; counter++; } } }