Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank, Algorithm Solutions of Problem Solving Section in Java. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.
In this post, you will find the solution for Pangrams in Java-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.
Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.
Introduction To Algorithm
The word Algorithm means “a process or set of rules to be followed in calculations or other problem-solving operations”. Therefore Algorithm refers to a set of rules/instructions that step-by-step define how a work is to be executed upon in order to get the expected results.
Advantages of Algorithms:
- It is easy to understand.
- Algorithm is a step-wise representation of a solution to a given problem.
- In Algorithm the problem is broken down into smaller pieces or steps hence, it is easier for the programmer to convert it into an actual program.
Link for the Problem – Pangrams – Hacker Rank Solution
Pangrams – Hacker Rank Solution
Problem:
A pangram is a string that contains every letter of the alphabet. Given a sentence determine whether it is a pangram in the English alphabet. Ignore case. Return either pangram
or not pangram
as appropriate.
Example
![Pangrams in Algorithm | HackerRank Programming Solutions | HackerRank Problem Solving Solutions in Java [💯Correct] 2 image 89](https://technorj.com/wp-content/uploads/2021/12/image-89.png)
The string contains all letters in the English alphabet, so return pangram
.
Function Description
Complete the function pangrams in the editor below. It should return the string pangram
if the input string is a pangram. Otherwise, it should return not pangram
.
pangrams has the following parameter(s):
- string s: a string to test
Returns
- string: either
pangram
ornot pangram
Input Format
A single line with string .
Constraints
![Pangrams in Algorithm | HackerRank Programming Solutions | HackerRank Problem Solving Solutions in Java [💯Correct] 3 image 88](https://technorj.com/wp-content/uploads/2021/12/image-88.png)
Sample Input
Sample Input 0
We promptly judged antique ivory buckles for the next prize
Sample Output 0
pangram
Sample Explanation 0
All of the letters of the alphabet are present in the string.
Sample Input 1
We promptly judged antique ivory buckles for the prize
Sample Output 1
not pangram
Sample Explanation 0
The string lacks an x
.
Pangrams – Hacker Rank Solution
import java.util.Scanner; /** * @author Techno-RJ * */ public class Pangrams { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String line = sc.nextLine().toLowerCase(); boolean found = true; for (int i = 97; i <= 122; i++) { char ch = (char) i; if (line.indexOf(ch) == -1) { found = false; break; } } System.out.println(found ? "pangram" : "not pangram"); sc.close(); } }