From ce6a83557558afb0a0b02589b444137cd91cbaf0 Mon Sep 17 00:00:00 2001 From: Tanmay-312 Date: Sun, 16 Jun 2024 11:20:50 +0530 Subject: [PATCH] Added codes for 16 June --- GeeksForGeeks/June/16-6-24/GFG.java | 79 ++++++++++++++++++++++++++++ GeeksForGeeks/June/16-6-24/README.md | 2 + LeetCode/June/16-6-24/README.md | 2 + LeetCode/June/16-6-24/Solution.java | 21 ++++++++ 4 files changed, 104 insertions(+) create mode 100644 GeeksForGeeks/June/16-6-24/GFG.java create mode 100644 GeeksForGeeks/June/16-6-24/README.md create mode 100644 LeetCode/June/16-6-24/README.md create mode 100644 LeetCode/June/16-6-24/Solution.java diff --git a/GeeksForGeeks/June/16-6-24/GFG.java b/GeeksForGeeks/June/16-6-24/GFG.java new file mode 100644 index 0000000..28d1d2f --- /dev/null +++ b/GeeksForGeeks/June/16-6-24/GFG.java @@ -0,0 +1,79 @@ +//{ Driver Code Starts +import java.io.*; +import java.util.*; +import java.util.ArrayList; + +class IntArray { + public static int[] input(BufferedReader br, int n) throws IOException { + String[] s = br.readLine().trim().split(" "); + int[] a = new int[n]; + for (int i = 0; i < n; i++) a[i] = Integer.parseInt(s[i]); + + return a; + } + + public static void print(int[] a) { + for (int e : a) System.out.print(e + " "); + System.out.println(); + } + + public static void print(ArrayList a) { + for (int e : a) System.out.print(e + " "); + System.out.println(); + } +} + +class GFG { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int t; + t = Integer.parseInt(br.readLine()); + while (t-- > 0) { + + int n; + n = Integer.parseInt(br.readLine()); + + Solution obj = new Solution(); + ArrayList res = obj.getPrimes(n); + + IntArray.print(res); + } + } +} + +// } Driver Code Ends + + +class Solution +{ + public static ArrayList getPrimes(int n) + { + // code here + ArrayList list = new ArrayList<>(); + list.add(-1); + list.add(-1); + for (int i=2; i