You are viewing a single comment's thread. Return to all comments →
import java.io.*; import java.util.*; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); String phrase = in.nextLine(); phrase = phrase.toLowerCase(); phrase = phrase.trim(); phrase = phrase.replaceAll("\\s+", ""); int length = phrase.length(); char [] checkAlphabet = phrase.toCharArray(); Arrays.sort(checkAlphabet); int index = 0; int charVal; int nextCharVal; if(Character.valueOf(checkAlphabet[index])==97 && length>25){ while(checkAlphabet[index]!='z' && index<=length-2){ charVal = Character.valueOf(checkAlphabet[index]); nextCharVal = Character.valueOf(checkAlphabet[index+1]); if(charVal == nextCharVal || charVal+1 == nextCharVal){ index++; } else { System.out.println("not pangram"); return; } } } else{ System.out.println("not pangram"); return; } in.close(); System.out.println("pangram"); return; } }
GREAT CODE SIGI!! My previous one was failing number 3 for some reason. Sorry ahead of time for unreadability.
Seems like cookies are disabled on this browser, please enable them to open this website
Pangrams
You are viewing a single comment's thread. Return to all comments →
GREAT CODE SIGI!! My previous one was failing number 3 for some reason. Sorry ahead of time for unreadability.