Skip to content

Commit

Permalink
Added codes for 1 Feb
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanmay-312 committed Feb 1, 2024
1 parent 35b4dfc commit 2447c8e
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
53 changes: 53 additions & 0 deletions GeeksForGeeks/February/1-2-24/GFG.java
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
2 changes: 2 additions & 0 deletions GeeksForGeeks/February/1-2-24/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Time complexity - O(logn)
Space complexity - O(1)
2 changes: 2 additions & 0 deletions LeetCode/February/1-2-24/README.md
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)
19 changes: 19 additions & 0 deletions LeetCode/February/1-2-24/Solution.java
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;
}
}

0 comments on commit 2447c8e

Please sign in to comment.