-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35b4dfc
commit 2447c8e
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//{ Driver Code Starts | ||
//Initial template for JAVA | ||
|
||
import java.lang.*; | ||
import java.io.*; | ||
import java.util.*; | ||
|
||
|
||
// } Driver Code Ends | ||
//User function template for JAVA | ||
|
||
class Solution | ||
{ | ||
//Function to check if a string is Pangram or not. | ||
public static boolean checkPangram (String str) | ||
{ | ||
// your code here | ||
Set<Character> set = new HashSet<>(); | ||
|
||
for (char ch : str.toCharArray()) | ||
{ | ||
if (ch >= 'a' && ch <= 'z') | ||
set.add(ch); | ||
|
||
if (ch >= 'A' && ch <= 'Z') | ||
{ | ||
ch = Character.toLowerCase(ch); | ||
set.add(ch); | ||
} | ||
} | ||
|
||
return set.size() == 26; | ||
} | ||
} | ||
|
||
//{ Driver Code Starts. | ||
|
||
class GFG | ||
{ | ||
public static void main (String[] args) throws IOException | ||
{ | ||
BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); | ||
int t=Integer.parseInt(br.readLine()); | ||
while(t-->0) | ||
{ | ||
String s=br.readLine().trim(); | ||
|
||
System.out.println(new Solution().checkPangram (s)==true?1:0); | ||
} | ||
|
||
} | ||
} | ||
// } Driver Code Ends |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Time complexity - O(logn) | ||
Space complexity - O(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Time complexity - O(nlogn) or O(sort) | ||
Space complexity - O(n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Solution | ||
{ | ||
public int[][] divideArray(int[] nums, int k) | ||
{ | ||
int[][] ans = new int[nums.length / 3][3]; | ||
|
||
Arrays.sort(nums); | ||
|
||
for (int i = 2; i < nums.length; i += 3) | ||
{ | ||
if (nums[i] - nums[i - 2] > k) | ||
return new int[0][]; | ||
|
||
ans[i / 3] = new int[] {nums[i - 2], nums[i - 1], nums[i]}; | ||
} | ||
|
||
return ans; | ||
} | ||
} |