Algorithm/Strings/Pangrams
Question : https://www.hackerrank.com/challenges/pangrams
Input:
We promptly judged antique ivory buckles for the next prize
Output:
pangram
Explanation:
In the first test case, the answer is pangram because the sentence contains all the letters of the English alphabet.
Solution:
import java.util.*;
import java.io.*;
class pangram{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
String s = in.nextLine(); //input of a sentence
int length = s.length(); // taking the legth of a string
s=s.toLowerCase();
char c[] = s.toCharArray(); // converting it into a char array c[]
//Explanation//
/*since now I have a char array
*I will perform basic operation on it
* (1). i will pick the char at starting pos
* and count it as coutn++ and count rest
* of that char to some non alphabetical
* this goes on until my count becomes
* 26. If its a pangram then its a
* pangram else its not...(Thank You) */
int i=0,count=0;
while(i<length){
char temp=c[i];
if(temp>=97&&temp<=122){
count++;
for(int j=0;j<length;j++){
if(temp==c[j])
c[j]='0';
import java.io.*;
class pangram{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
String s = in.nextLine(); //input of a sentence
int length = s.length(); // taking the legth of a string
s=s.toLowerCase();
char c[] = s.toCharArray(); // converting it into a char array c[]
//Explanation//
/*since now I have a char array
*I will perform basic operation on it
* (1). i will pick the char at starting pos
* and count it as coutn++ and count rest
* of that char to some non alphabetical
* this goes on until my count becomes
* 26. If its a pangram then its a
* pangram else its not...(Thank You) */
int i=0,count=0;
while(i<length){
char temp=c[i];
if(temp>=97&&temp<=122){
count++;
for(int j=0;j<length;j++){
if(temp==c[j])
c[j]='0';