├── 2024 BATCH Q1
├── Third Last Consonant Q.txt
└── Third Last Consonant.java
├── 2024 BATCH Q2
├── Castle Stone Q.txt
└── Castle Stone.java
├── APTI EXAM PRE ASSESSMENT 1.pdf
├── Book - Elements of Programming Interviews in Java. The Insiders’ Guide.pdf
├── CampusRecruitmentBook.pdf
├── README.md
├── Set Wise Solution
├── Set - 1
│ ├── Number_1.java
│ ├── Number_10.java
│ ├── Number_11.java
│ ├── Number_12.java
│ ├── Number_13.java
│ ├── Number_14.java
│ ├── Number_15.java
│ ├── Number_2.java
│ ├── Number_3.java
│ ├── Number_4.java
│ ├── Number_5.java
│ ├── Number_6.java
│ ├── Number_7.java
│ ├── Number_8.java
│ └── Number_9.java
├── Set - 2
│ ├── Number_1.java
│ ├── Number_11.java
│ ├── Number_12.java
│ ├── Number_13.java
│ ├── Number_14.java
│ ├── Number_15.java
│ ├── Number_2.java
│ ├── Number_3.java
│ ├── Number_4.java
│ ├── Number_5.java
│ ├── Number_6.java
│ ├── Number_7.java
│ ├── Number_8.java
│ └── Number_9.java
├── Set - 3
│ ├── Number_1.java
│ ├── Number_10.java
│ ├── Number_11.java
│ ├── Number_12.java
│ ├── Number_13.java
│ ├── Number_14.java
│ ├── Number_15.java
│ ├── Number_2.java
│ ├── Number_3.java
│ ├── Number_4.java
│ ├── Number_5.java
│ ├── Number_6.java
│ ├── Number_7.java
│ ├── Number_8.java
│ └── Number_9.java
├── Set - 4
│ ├── Number_1.java
│ ├── Number_10.java
│ ├── Number_12.java
│ ├── Number_13.java
│ ├── Number_14.java
│ ├── Number_15.java
│ ├── Number_2.java
│ ├── Number_4.java
│ ├── Number_5.java
│ ├── Number_6.java
│ ├── Number_7.java
│ ├── Number_8.java
│ └── Number_9.java
└── Set - 5
│ ├── Number_!0.java
│ ├── Number_13.java
│ ├── Number_14.java
│ ├── Number_15.java
│ ├── Number_3.java
│ ├── Number_5.java
│ ├── Number_7.java
│ ├── Number_8.java
│ └── Number_9.java
├── Set-1.pdf
├── Set-2.pdf
├── Set-3.pdf
├── Set-4.pdf
└── Set-5.pdf
/2024 BATCH Q1/Third Last Consonant Q.txt:
--------------------------------------------------------------------------------
1 | Problem Statement
2 |
3 | You are given a string, str. Print the third last consonant of str.
4 |
5 | Note:
6 |
7 | 1. str will always have more than or equal to 3 consonants. 2. All the letters in the English alphabet other than vowels (a, e, i, o, u) are
8 |
9 | consonants.
10 |
11 | Input Format:
12 |
13 | Each test case consists of two lines of input,
14 |
15 | .
16 |
17 | The first line contains a single integer, i.e. the length of the string str..
18 |
19 | The second line contains a string, i.e. str. Input will be read from the STDIN by the candidate
20 |
21 | Output Format:
22 |
23 | The output consists of a single character, i.e. the third last consonant of str.
24 |
25 | The output will be matched to the candidate's output printed on the STDOUT
--------------------------------------------------------------------------------
/2024 BATCH Q1/Third Last Consonant.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 |
3 | public class Main {
4 | public static void main(String[] args) {
5 | Scanner scanner = new Scanner(System.in);
6 |
7 | int length = scanner.nextInt();
8 | String str = scanner.next();
9 |
10 | int consonantCount = 0;
11 | char thirdLastConsonant = ' ';
12 |
13 | for (int i = str.length() - 1; i >= 0; i--) {
14 | char ch = str.charAt(i);
15 | if (isConsonant(ch)) {
16 | consonantCount++;
17 | if (consonantCount == 3) {
18 | thirdLastConsonant = ch;
19 | break;
20 | }
21 | }
22 | }
23 |
24 | System.out.println(thirdLastConsonant);
25 |
26 | scanner.close();
27 | }
28 |
29 | private static boolean isConsonant(char ch) {
30 | return !("aeiouAEIOU".indexOf(ch) >= 0);
31 | }
32 | }
--------------------------------------------------------------------------------
/2024 BATCH Q2/Castle Stone Q.txt:
--------------------------------------------------------------------------------
1 | Problem Statement
2 |
3 | To build a castle a crane has to lift stones and transport. You are given an integer cap denoting the maximum weight a crane can carry in a single turn and a positive Integer array stones consisting of n stones, stones array contains the weight of all the n stones. Find minimum numbers of turns required by the crane to transport all stones of the array stones, such that for each turn not more than 2 stones can be transported.
4 |
5 | Note:
6 |
7 | The weight of each stone of stones array is less than or equal to the maximum capacity of the crane.
8 |
9 | Input Format:
10 |
11 | Each test case consists of three lines of input: The first line contains an integer cap, l.e. the maximum lifting capacity of the crane. The second line contains an integer n, i.e. the number of stones in the array. The third line contains n integers separated by space, i.e. the weight of stones in the array stones
12 |
13 | Input will be read from the STDIN by the candidate
14 |
15 | Output Format:
16 |
17 | The output contains a single integer i.e., the minimum number of turns required to transport all the stones
--------------------------------------------------------------------------------
/2024 BATCH Q2/Castle Stone.java:
--------------------------------------------------------------------------------
1 | import java.util.Arrays;
2 | import java.util.Scanner;
3 |
4 | public class Main {
5 | public static void main(String[] args) {
6 | Scanner scanner = new Scanner(System.in);
7 |
8 | int cap = scanner.nextInt();
9 | int n = scanner.nextInt();
10 | int[] stones = new int[n];
11 |
12 | for (int i = 0; i < n; i++) {
13 | stones[i] = scanner.nextInt();
14 | }
15 |
16 | Arrays.sort(stones);
17 |
18 | int turns = 0;
19 | int left = 0;
20 | int right = n - 1;
21 |
22 | while (left <= right) {
23 | if (stones[right] + stones[left] <= cap) {
24 | left++;
25 | }
26 | right--;
27 | turns++;
28 | }
29 |
30 | System.out.println(turns);
31 |
32 | scanner.close();
33 | }
34 | }
--------------------------------------------------------------------------------
/APTI EXAM PRE ASSESSMENT 1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaal-coder/PrePlacementAssesmentExam/3f0d0c20fcb5e003258ecfac890cb3de63fd087a/APTI EXAM PRE ASSESSMENT 1.pdf
--------------------------------------------------------------------------------
/Book - Elements of Programming Interviews in Java. The Insiders’ Guide.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaal-coder/PrePlacementAssesmentExam/3f0d0c20fcb5e003258ecfac890cb3de63fd087a/Book - Elements of Programming Interviews in Java. The Insiders’ Guide.pdf
--------------------------------------------------------------------------------
/CampusRecruitmentBook.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaal-coder/PrePlacementAssesmentExam/3f0d0c20fcb5e003258ecfac890cb3de63fd087a/CampusRecruitmentBook.pdf
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
PrePlacementAssesmentExam Study Material
2 |
3 |
4 | The above are PDFs 📚 that may help students prepare for Pre Placement Assesment Exam 📝
5 |
6 |
7 | Any contribution 🎯 made to this will be highly appreciated.💯
8 |
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 1/Number_1.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kaal-coder/PrePlacementAssesmentExam/3f0d0c20fcb5e003258ecfac890cb3de63fd087a/Set Wise Solution/Set - 1/Number_1.java
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 1/Number_10.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_10{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | String s=sc.nextLine();
7 | int a[] = new int[26];
8 | for(char c:s.toCharArray())
9 | {
10 | a[c-'a']++;
11 | }
12 | int m=Integer.MAX_VALUE,n=Integer.MIN_VALUE;
13 | for(int i=0;i<26;i++)
14 | {
15 | if(na[i]&&a[i]!=0)
20 | {
21 | m=a[i];
22 | }
23 | }
24 | if(m==n)
25 | {
26 | System.out.println("The frequencies are same");
27 | }
28 | else
29 | {
30 | System.out.println("The maximum frequency is "+n + " the minimum frequency is "+m);
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 1/Number_11.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_11{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | String s=sc.nextLine();
7 | task(s , 0 , s.length());
8 |
9 | }
10 | static void task(String s , int i , int n)
11 | {
12 | if(i==n)
13 | {
14 | System.out.println(s);
15 | }
16 | for(int j=i;j=a[i])
12 | {
13 | b[i]=n/a[i];
14 | n=n-b[i]*a[i];
15 | }
16 | }
17 | for(int i=0;i<7;i++)
18 | {
19 | System.out.println(a[i] +" -> "+b[i]);
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 1/Number_13.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_13{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | int n=sc.nextInt();
7 | int f=n;
8 | while(n!=0)
9 | {
10 | System.out.print(n%10+" ");
11 | n/=10;
12 | }
13 | if(f%9==0)
14 | {
15 | System.out.println("\n"+f+" is Divisible by 9");
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 1/Number_14.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_14{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | int n=12;
7 | int k=String.valueOf(n).length();
8 | if(k%2==0)
9 | {
10 | int a[] = new int[10];
11 | while(n!=0)
12 | {
13 | a[n%10]++;
14 | n/=10;
15 | }
16 | for(int i=0;i<10;i++)
17 | {
18 | if(a[i]%2==1)
19 | {
20 | System.out.println(1);
21 | return;
22 | }
23 | }
24 | System.out.println(2);
25 | }
26 | else
27 | {
28 | int a[] = new int[10];
29 | while(n!=0)
30 | {
31 | a[n%10]++;
32 | n/=10;
33 | }
34 | int c=0;
35 | for(int i=0;i<10;i++)
36 | {
37 | if(a[i]%2==1)
38 | {
39 | c++;
40 | }
41 | if(c>1)
42 | {
43 | System.out.print(1);
44 | return;
45 | }
46 | }
47 | System.out.println(2);
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 1/Number_15.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_15{
3 |
4 | public static void main(String []args){
5 | int n=5;
6 | for(int i=1;i<=n;i++)
7 | {
8 | for(int b=1;b<=n-i;b++)
9 | {
10 | System.out.print(" ");
11 | }
12 | if(i>=2)
13 | {
14 | for(int k=1;k<=i;k++)
15 | {
16 | System.out.print(k+" ");
17 | }
18 | for(int k='A'+i;k>66;k--)
19 | {
20 | char p=(char)(k-2);
21 | System.out.print(p+" ");
22 | }
23 | }
24 | else
25 | {
26 | System.out.print(i);
27 | }
28 | System.out.println();
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 1/Number_2.java:
--------------------------------------------------------------------------------
1 |
2 | import java.util.*;
3 | public class Number_2{
4 |
5 | public static void main(String []args){
6 | Scanner sc=new Scanner(System.in);
7 | int a=sc.nextInt();
8 | System.out.println(a>>2);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 1/Number_3.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_3{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | int n=sc.nextInt();
7 | int a[] = new int[n];
8 | for(int i=0;i9)
8 | {
9 | n=task(n);
10 | }
11 | System.out.println(n);
12 | }
13 | static int task(int n)
14 | {
15 | int s=0;
16 | while(n!=0)
17 | {
18 | s+=n%10;
19 | n/=10;
20 | }
21 | return s;
22 | }
23 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 1/Number_7.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_7{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | int n=sc.nextInt();
7 | int a[] = new int[n];
8 | for(int i=0;is)
21 | {
22 | p=s;
23 | s=a[i];
24 | }
25 | else if(a[i]>p&&p!=s)
26 | {
27 | p=a[i];
28 | }
29 | }
30 | if(p==Integer.MIN_VALUE)
31 | {
32 | System.out.println("No second largest element");
33 | }
34 | else
35 | {
36 | System.out.println("The second largest element is "+p);
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 1/Number_8.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_8{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | int n=sc.nextInt();
7 | int a[] = new int[n];
8 | for(int i=0;i1)
14 | {
15 | for(int k=1;k<=i;k++)
16 | {
17 | System.out.print(k);
18 | }
19 | for(int k=i-1;k>=1;k--)
20 | {
21 | System.out.print(k);
22 | }
23 | System.out.println();
24 | }
25 | else
26 | {
27 | System.out.println("1");
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 2/Number_13.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_13{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | int n=sc.nextInt();
7 | int s=0;
8 | for(int i=1,m=1;i<=n;i++,m+=2)
9 | {
10 | if(i%2==1)
11 | {
12 | s+=m;
13 | }
14 | else
15 | {
16 | s-=m;
17 | }
18 | }
19 | System.out.println(s);
20 | }
21 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 2/Number_14.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 |
3 | public class Number_14 {
4 |
5 | public static void main(String[] args) {
6 | Scanner sc = new Scanner(System.in);
7 | int a = 0, b = 1, c, n = 15;
8 | if (n == 1)
9 | {
10 | System.out.println("0");
11 | return;
12 | }
13 | else if (n == 2)
14 | {
15 | System.out.println("1");
16 | return;
17 | }
18 | else
19 | {
20 | System.out.print(a + " " + b + " ");
21 | for (int i = 3; i <= n; i++)
22 | {
23 | c = a + b;
24 | a = b;
25 | b = c;
26 | System.out.print(c + " ");
27 | }
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 2/Number_15.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_15{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | int n=sc.nextInt();
7 | int m=sc.nextInt();
8 | int s=0,i=0;
9 | while(m!=0)
10 | {
11 | s=s+(n*(m%10*(int)(Math.pow(10,i++))));
12 | m/=10;
13 | }
14 | System.out.println(s);
15 | }
16 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 2/Number_2.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_2{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | String s=sc.nextLine();
7 | String p="";
8 | int k=s.length();
9 | for(int i=0;i=0;i--)
9 | {
10 | char c=s.charAt(i);
11 | if(c==' ')
12 | {
13 | f=f+p+" ";
14 | p="";
15 | }
16 | else
17 | {
18 | p=c+p;
19 | }
20 | }
21 | f=f+p;
22 | System.out.println(f);
23 | }
24 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 2/Number_4.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_4{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | String s="Welcome to iter";
7 | String p="";
8 | int k=s.length();
9 | for(int i=0;i nm=new LinkedHashSet<>();
8 | for(char k:s.toCharArray())
9 | {
10 | nm.add(k);
11 | }
12 | StringBuilder kk=new StringBuilder();
13 | for(Character c:nm)
14 | {
15 | kk.append(c);
16 | }
17 | System.out.println(kk.toString());
18 | }
19 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 2/Number_6.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_6{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | String s=sc.nextLine();
7 | task(s , 0 , "");
8 | }
9 | static void task(String s , int i , String cur)
10 | {
11 | if(i==s.length())
12 | {
13 | System.out.println(cur);
14 | return;
15 | }
16 | task(s,i+1,s.charAt(i)+cur);
17 | task(s,i+1,cur);
18 | }
19 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 2/Number_7.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_7{
3 | public static void main(String []args){
4 | Scanner sc=new Scanner(System.in);
5 | String s=sc.nextLine();
6 | LinkedHashSet nm=new LinkedHashSet<>();
7 | int c[] = new int[26];
8 | for(char k:s.toCharArray())
9 | {
10 | if(k!=' ')
11 | {
12 | nm.add(k);
13 | c[k-'a']++;
14 | }
15 | }
16 | for(Character k:nm)
17 | {
18 | System.out.println(k + " "+(c[k-'a']));
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 2/Number_8.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_8{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | int n=sc.nextInt();
7 | int a[] = new int[n];
8 | for(int i=0;i nm=new ArrayList<>();
8 | for(int i=0;i nm=new ArrayList<>();
8 | int k=sc.nextInt();
9 | for(int i=1;i<=n;i++)
10 | {
11 | if(n%i==0)
12 | {
13 | nm.add(i);
14 | }
15 | }
16 | System.out.println(nm.get(k-1));
17 | }
18 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 3/Number_11.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_11{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | int n=sc.nextInt();
7 | int a[] = new int[10];
8 | while(n!=0)
9 | {
10 | a[n%10]++;
11 | n/=10;
12 | }
13 | StringBuilder nm=new StringBuilder();
14 | for(int i=1;i<10;i++)
15 | {
16 | for(int j=1;j<=a[i];j++)
17 | {
18 | nm.append(i);
19 | if(nm.length()==0 || a[0]==0)
20 | {
21 | continue;
22 | }
23 | else
24 | {
25 | for(int f=1;f<=a[0];f++)
26 | {
27 | nm.append(0);
28 | }
29 | a[0]=0;
30 | }
31 | }
32 | }
33 | System.out.println(nm);
34 | }
35 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 3/Number_12.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_12{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | int n=sc.nextInt();
7 | int a=1,b=1,c=0;
8 | if(n==1)
9 | {
10 | System.out.println(a);
11 | }
12 | else if(n==2)
13 | {
14 | System.out.println(a+" 2");
15 | }
16 | else if(n==3)
17 | {
18 | System.out.println(a+" 2 "+b);
19 | }
20 | int f=2;
21 | for(int i=4;i<=n;i++)
22 | {
23 | if(i%2==0)
24 | {
25 | f=prime(f+1);
26 | }
27 | else
28 | {
29 | c=a+b;
30 | a=b;
31 | b=c;
32 | }
33 | }
34 | if(n%2==0)
35 | {
36 | System.out.println(f);
37 | }
38 | else
39 | {
40 | System.out.println(c);
41 | }
42 |
43 | }
44 | static int prime(int n)
45 | {
46 | while(true)
47 | {
48 | int k=0;
49 | for(int i=2;i<=Math.sqrt(n);i++)
50 | {
51 | if(n%i==0)
52 | {
53 | k=1;
54 | break;
55 | }
56 | }
57 | if(k==1)
58 | {
59 | n++;
60 | }
61 | else
62 | {
63 | return n;
64 | }
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 3/Number_13.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_13{
3 | static int a[][][] = new int[5001][5001][5];
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | int n=sc.nextInt();
7 | for(int i=0;i nm=new HashMap<>();
9 | for(int i=0;i kk=new ArrayList<>();
17 | for(int i=0;i=1;k--)
18 | {
19 | System.out.print(k+"");
20 | }
21 | System.out.println();
22 | }
23 | for(int i=n-1;i>=1;i--)
24 | {
25 | for(int b=1;b<=n-i;b++)
26 | {
27 | System.out.print(" ");
28 | }
29 | for(int k=1;k<=i;k++)
30 | {
31 | System.out.print(k+"");
32 | }
33 | for(int k=i-1;k>=1;k--)
34 | {
35 | System.out.print(k+"");
36 | }
37 | System.out.println();
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 3/Number_2.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_2{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | int n=sc.nextInt();
7 | int a[] = new int[n];
8 | for(int i=0;i=0;i--)
19 | {
20 | for(int j=1;j<=b[i];j++)
21 | {
22 | nm.append(i);
23 | }
24 | }
25 | System.out.println(nm.toString());
26 | }
27 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 3/Number_3.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_3{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | int n=sc.nextInt();
7 | for(int i=n-1;i>=0;i--)
8 | {
9 | if(n%i==0)
10 | {
11 | System.out.println(i);
12 | break;
13 | }
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 3/Number_4.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_4{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | String s=sc.nextLine();
7 | int c[] = new int[26];
8 | for(char p:s.toCharArray())
9 | {
10 | c[p-'a']++;
11 | }
12 | int f=0;
13 | for(int i=0;i<26;i++)
14 | {
15 | if(c[i]==1)
16 | {
17 | f++;
18 | }
19 | }
20 | System.out.println(f);
21 | }
22 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 3/Number_5.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_5{
3 | public static void main(String []args){
4 | Scanner sc=new Scanner(System.in);
5 | int n=sc.nextInt();
6 | int a[]=new int[n];
7 | for(int i=0;i nm=new HashMap<>();
13 | int c=0;
14 | for(int i=0;i nm=new HashMap<>();
13 | for(int i=0;i nm=new HashMap<>();
9 | for(int i=0;i<17;i++)
10 | {
11 | a[i]=sc.nextInt();
12 | nm.put(a[i] , nm.getOrDefault(a[i] ,0)+1);
13 | }
14 |
15 | for(int k:nm.keySet())
16 | {
17 | System.out.println(k+ " " + nm.get(k));
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 4/Number_1.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_1{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | int n=sc.nextInt();
7 | int x=sc.nextInt();
8 | int s=0,m=1;
9 | for(int i=1;i<=n;i++,m+=2)
10 | {
11 | int h=fact(m);
12 | if(i%2==1)
13 | {
14 | s+=(int)(Math.pow(x,m))/h;
15 | }
16 | else
17 | {
18 | s-=(int)(Math.pow(x,m))/h;
19 | }
20 | }
21 | }
22 | static int fact(int n)
23 | {
24 | int f=1;
25 | for(int i=1;i<=n;i++)
26 | {
27 | f*=i;
28 | }
29 | return f;
30 | }
31 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 4/Number_10.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_10{
3 | public static void main(String []args){
4 | Scanner sc=new Scanner(System.in);
5 | int m=2;
6 | for(int i=1;i<=1000;i++)
7 | {
8 | if(prime(m)&&prime(m+2))
9 | {
10 | System.out.println(m+" "+(m+2));
11 | }
12 | m++;
13 | }
14 | }
15 | static boolean prime(int n)
16 | {
17 | if(n==2)
18 | {
19 | return true;
20 | }
21 | for(int i=2;i<=Math.sqrt(n);i++)
22 | {
23 | if(n%i==0)
24 | {
25 | return false;
26 | }
27 | }
28 | return true;
29 | }
30 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 4/Number_12.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_12{
3 |
4 | public static void main(String []args){
5 | Scanner sc=new Scanner(System.in);
6 | int n=sc.nextInt();
7 | String s="";
8 | while(n!=0)
9 | {
10 | s=(n%8)+s;
11 | n/=8;
12 | }
13 | System.out.println(s);
14 | }
15 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 4/Number_13.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_13{
3 | public static void main(String []args){
4 | Scanner sc=new Scanner(System.in);
5 | int n=sc.nextInt();
6 | int a[] = new int[n];
7 | for(int i=0;in)
19 | {
20 | System.out.println("OverFlow");
21 | }
22 | else if(pos==n)
23 | {
24 | for(int i=0;ipos)
38 | {
39 | b[i]=a[i-1];
40 | i--;
41 | }
42 | b[i]=ele;
43 | i--;
44 | while(i>=0)
45 | {
46 | b[i]=a[i];
47 | i--;
48 | }
49 | for(int j:b)
50 | {
51 | System.out.print(j+" ");
52 | }
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/Set Wise Solution/Set - 4/Number_14.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Number_14{
3 | public static void main(String []args){
4 | Scanner sc=new Scanner(System.in);
5 | int n=sc.nextInt();
6 | int m=sc.nextInt();
7 | int a[][] = new int[n][m];
8 | for(int i=0;ia[j+1])
16 | {
17 | int d=a[j];
18 | a[j]=a[j+1];
19 | a[j+1]=d;
20 | }
21 | }
22 | }
23 | for(int i=0;i=0 && a[j]>v)
16 | {
17 | a[j+1]=a[j];
18 | j--;
19 | }
20 | a[j+1]=v;
21 | }
22 | for(int i=0;i