├── day_61.java ├── day_70.java ├── day_77.java ├── day_74.java ├── day_68.java ├── day_64.java ├── day_66.java ├── day_79.java ├── day_67.java ├── day_72.java ├── day_78.java ├── day_62.java ├── day_75.java ├── day_69.java ├── README.md ├── day_63.java ├── day_71.java ├── day_65.java ├── day_76.java ├── day_80.java └── day_73.java /day_61.java: -------------------------------------------------------------------------------- 1 | class Solution {//sort the people based on height 2 | public String[] sortPeople(String[] names, int[] heights) { 3 | for(int i=0;i ip=new ArrayList<>(); 9 | for(String i : str){ 10 | ip.add(Integer.parseInt(i)); 11 | } 12 | int c=0; 13 | Set set=new HashSet<>(); 14 | for(int i=0;i='a'&&i<='z'||i>='A'&&i<='Z')) {System.out.print("Invalid");return;} 12 | if(Vowel.contains(""+i)){ 13 | ans+='1';C++; 14 | }else ans+=i; 15 | } 16 | System.out.print(ans+" "+C); 17 | 18 | } 19 | } 20 | // #include 21 | // #include 22 | 23 | // int main() 24 | // { 25 | // int a; 26 | // scanf("%d",&a); 27 | // int ar[a]; 28 | // for(int i=0;i=0;i--){ 30 | // int r=ar[i]%10; 31 | // if(r==0){ 32 | // if(ar[i]!=0) 33 | // printf("%d ",ar[i]); 34 | // } 35 | // else if(ar[i]%r==0) 36 | // printf("%d ",ar[i]); 37 | // } 38 | // }-->divisible by its unit digit 39 | -------------------------------------------------------------------------------- /day_79.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Hello { 3 | 4 | public static void main(String[] args) { 5 | //N terms Double Series; 6 | Scanner sc=new Scanner(System.in); 7 | int n=sc.nextInt(); 8 | int x=sc.nextInt(); 9 | int y=sc.nextInt(); 10 | int i=1; 11 | while(i<=n/2){ 12 | if(i%2==1) 13 | System.out.print(i*x+1+" "+(i*y+1)+" "); 14 | else 15 | System.out.print(i*x-1+" "+(i*y-1)+" "); 16 | i++; 17 | } 18 | if(n%2==1) System.out.print((i%2==0)?i*x-1:i*x+1); 19 | 20 | } 21 | } 22 | import java.util.*; 23 | public class Hello { 24 | 25 | public static void main(String[] args) { 26 | //Probablitity N Balls 27 | Scanner sc=new Scanner(System.in); 28 | int a=sc.nextInt(); 29 | int b=sc.nextInt(); 30 | int c=sc.nextInt(); 31 | int d=Math.min(a,c); 32 | int i=d; 33 | int j=0; 34 | while(i>=0&&j<=b){ 35 | if(i+j==c){ 36 | System.out.println(i+" "+j); 37 | i--; 38 | j=0; 39 | } 40 | 41 | 42 | if(j==b){ 43 | i=d; 44 | }j++; 45 | } 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /day_67.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Hello { 3 | 4 | public static void main(String[] args) { 5 | //Integer Atleast One Zero 6 | Scanner sc=new Scanner(System.in); 7 | int x=sc.nextInt(); 8 | int y=sc.nextInt(); 9 | boolean p=true; 10 | for(int i=x;i<=y;i++){ 11 | String r=Integer.toString(i); 12 | if(r.contains("0")){ 13 | p=false; 14 | System.out.print(i+" "); 15 | } 16 | } 17 | if(p) System.out.print(-1); 18 | 19 | } 20 | } 21 | import java.util.*; 22 | public class Hello { 23 | 24 | public static void main(String[] args) { 25 | //Matrix -Row&Column Pattern 26 | Scanner sc=new Scanner(System.in); 27 | int r=sc.nextInt(); 28 | int c=sc.nextInt(); 29 | int[][] ar=new int[r][c]; 30 | for(int i=0;i0){ 10 | if(prime(n)){ 11 | a--; 12 | p*=n; 13 | } 14 | n++; 15 | } 16 | System.out.print(p); 17 | } 18 | static boolean prime(int a){ 19 | if(a<=3) return true; 20 | if(a%2==0||a%3==0) return false; 21 | for(int i=4;i*i<=a;i++){ 22 | if(a%i==0) return false; 23 | }return true; 24 | } 25 | 26 | } 27 | import java.util.*; 28 | public class Hello { 29 | 30 | public static void main(String[] args) { 31 | //Words Alternate Min&Max 32 | String[] str=new Scanner(System.in).nextLine().split(" "); 33 | int i=0; 34 | String rs=""; 35 | int j=str.length-1; 36 | while(istr[j].length()){ 50 | if(i%2==0){ 51 | ans=str[j]; 52 | } 53 | else ans=str[i]; 54 | } 55 | rs+=(ans+" "); 56 | j--; 57 | i++; 58 | } 59 | System.out.print(rs.trim()); 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /day_62.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Hello { 3 | 4 | public static void main(String[] args) { 5 | //Tooggle Exactly One Bit 6 | Scanner sc=new Scanner(System.in); 7 | int a=sc.nextInt(); 8 | String bi=Integer.toBinaryString(a); 9 | int max=0; 10 | int n=bi.length(); 11 | for(int i=0;i se=new ArrayList<>(); 51 | for(int i=1;i<=b;i++) se.add(i); 52 | int c=0; 53 | for(int i=1;i<=a;i++){ 54 | for(int j=0;j set=new LinkedHashSet<>(); 31 | for(String i:fs){ 32 | if(i.length()!=k) continue; 33 | for(String j:ls){ 34 | if(j.length()!=k) continue; 35 | if(i.equals(j)) { 36 | set.add(i); 37 | break; 38 | } 39 | } 40 | } 41 | if(set.isEmpty()){ System.out.print(-1);return;} 42 | for(String i:set)System.out.print(i+" "); 43 | } 44 | } 45 | import java.util.*; 46 | public class Hello { 47 | 48 | public static void main(String[] args) { 49 | //Count N integers in M integers 50 | Scanner sc=new Scanner(System.in); 51 | int f=sc.nextInt(); 52 | int s=sc.nextInt(); 53 | int[] fa=new int[f]; 54 | int[] sa=new int[s]; 55 | for(int i=0;i ip=new ArrayList<>(); 81 | while(sc.hasNext()){ 82 | ip.add(sc.next()); 83 | } 84 | Collections.sort(ip); 85 | for(String i: ip){ 86 | System.out.print(i+" "); 87 | } 88 | 89 | 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /day_65.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Hello { 3 | 4 | public static void main(String[] args) { 5 | //Reverse Equal Vowels and Consonants; 6 | Scanner sc=new Scanner(System.in); 7 | String ip=sc.nextLine(); 8 | String[] k=ip.split("\\s"); 9 | for(String i:k){ 10 | if(count(i)){ 11 | System.out.print(rv(i)+" "); 12 | } 13 | else{ 14 | System.out.print(i+" "); 15 | } 16 | } 17 | 18 | } 19 | static boolean count(String a){ 20 | int c=0; 21 | String v="aeiouAEIOU"; 22 | for(char j:a.toCharArray()){ 23 | 24 | if(v.contains(""+j)) c++; 25 | } 26 | return c==a.length()-c; 27 | } 28 | static String rv(String a){ 29 | String ans=""; 30 | for(char i:a.toCharArray()){ 31 | ans=i+ans; 32 | } 33 | return ans; 34 | 35 | } 36 | } 37 | //this code tells about the equalsIgnoreCase: it is in C programming 38 | // #include 39 | // #include 40 | // #include 41 | // int cmp(char* a,char* b){ 42 | // if(strlen(a)!=strlen(b)) return 1; 43 | // else{ 44 | // for(int i=0;i=97){ 57 | // a[i]-=32; 58 | // } 59 | // } 60 | // for(int i=0;i=97){ 62 | // b[i]-=32; 63 | // } 64 | // } 65 | // if(cmp(a,b)==0) 66 | // printf("YES"); 67 | // else 68 | // printf("NO"); 69 | // } 70 | 71 | import java.util.*; 72 | public class Hello { 73 | 74 | public static void main(String[] args) { 75 | //U -Shaped Layers Matrix 76 | Scanner sc=new Scanner(System.in); 77 | int r=sc.nextInt(); 78 | int c=sc.nextInt(); 79 | int ar[][]=new int[r][c]; 80 | for(int i=0;i=0;l--){ 94 | System.out.print(ar[l][c-i-1]+" "); 95 | } 96 | 97 | System.out.println(); 98 | } 99 | 100 | 101 | } 102 | } 103 | import java.util.*; 104 | public class Hello { 105 | 106 | public static void main(String[] args) { 107 | //longest prefix divisible by D; 108 | Scanner sc=new Scanner(System.in); 109 | String ip=sc.next(); 110 | int d=sc.nextInt(); 111 | for(int i=ip.length()-1;i>=0;i--){ 112 | int num=Integer.parseInt(ip.substring(0,i+1)); 113 | if(num%d==0){ 114 | System.out.print(num); 115 | return; 116 | } 117 | } 118 | System.out.print(-1); 119 | 120 | } 121 | } 122 | import java.util.*; 123 | public class Hello { 124 | 125 | public static void main(String[] args) { 126 | //Order by Integers; 127 | Scanner sc=new Scanner(System.in); 128 | int as=sc.nextInt(); 129 | int is=sc.nextInt(); 130 | ArrayList a=new ArrayList<>(); 131 | ArrayList I =new ArrayList<>(); 132 | 133 | for(int i=0;i0){ 52 | l++; 53 | if(l==ans.length){ 54 | l=0; 55 | } 56 | c--; } 57 | } 58 | an+=ans[l]; 59 | } 60 | // System.out.print(ans); 61 | return an; 62 | } 63 | } 64 | 65 | // 100328. Generate Binary Strings Without Adjacent Zeros 66 | // Solved 67 | // Medium 68 | // You are given a positive integer n. 69 | 70 | // A binary string x is valid if all 71 | // substrings 72 | // of x of length 2 contain at least one "1". 73 | 74 | // Return all valid strings with length n, in any order. 75 | 76 | 77 | 78 | // Example 1: 79 | 80 | // Input: n = 3 81 | 82 | // Output: ["010","011","101","110","111"] 83 | 84 | // Explanation: 85 | 86 | // The valid strings of length 3 are: "010", "011", "101", "110", and "111". 87 | 88 | // Example 2: 89 | 90 | // Input: n = 1 91 | 92 | // Output: ["0","1"] 93 | 94 | // Explanation: 95 | 96 | // The valid strings of length 1 are: "0" and "1". 97 | 98 | 99 | 100 | // Constraints: 101 | 102 | // 1 <= n <= 18 103 | 104 | class Solution { 105 | public List validStrings(int n) { 106 | List ans=new ArrayList<>(); 107 | int max=(int)Math.pow(2,n)-1; 108 | System.out.print(max); 109 | for(int i=0;i<=max;i++){ 110 | if(adjaZero(bin(Integer.toBinaryString(i),n))){ 111 | ans.add(bin(Integer.toBinaryString(i),n)); 112 | } 113 | } 114 | return ans; 115 | } 116 | static String bin(String a,int n){ 117 | 118 | String as=""; 119 | int c=n-a.length(); 120 | 121 | for(int i=0;i ans=new Stack<>(); 4 | for(int i=0;ival){ 51 | if(root.left!=null) 52 | root=root.left; 53 | else{ 54 | return null; 55 | } 56 | 57 | } 58 | else{ 59 | if(root.right!=null) 60 | root=root.right; 61 | else{ 62 | return null; 63 | } 64 | } 65 | } 66 | return null; 67 | } 68 | } 69 | class Solution { 70 | public List kidsWithCandies(int[] candies, int ec) { 71 | List ans=new ArrayList<>(); 72 | int max=candies[0]; 73 | for(int i=1;i=max); 76 | } 77 | return ans; 78 | } 79 | } 80 | 81 | class Solution { 82 | public String removeStars(String s) { 83 | Stack ans=new Stack<>(); 84 | for(int i=0;i0){oc--; 108 | str.append('1');} 109 | else 110 | str.append('0'); 111 | } 112 | str.append('1'); 113 | return str.toString(); 114 | } 115 | } 116 | import java.util.*; 117 | public class Hello { 118 | 119 | public static void main(String[] args) { 120 | //Replace - Four Directions 121 | Scanner sc=new Scanner(System.in); 122 | int a=sc.nextInt(); 123 | int b=sc.nextInt(); 124 | String mat[][]=new String[a][b]; 125 | for(int i=0;i=0&&ji>=0){ 134 | mat[ii--][ji--]="*"; 135 | 136 | } 137 | ii=iind; 138 | ji=jind; 139 | while(ii>=0&&ji=0){ 145 | mat[ii++][ji--]="*"; 146 | } 147 | ii=iind; 148 | ji=jind; 149 | while(ii 96 && a[i] <= 123) { 13 | lo += 1; 14 | } 15 | if (a[i] > 64 && a[i] <= 90) { 16 | // for check uppercase letters 17 | up += 1; 18 | } 19 | if (a[i] >= 33 && a[i] <= 47 || a[i] >= 58 && a[i] <= 64) { 20 | // for checking symbols 21 | sy += 1; 22 | } 23 | if (a[i] != ' ') { 24 | // for checking length 25 | le += 1; 26 | } 27 | if (a[i] >= 48 && a[i] <= 57) { 28 | // for checking numbers 29 | nu += 1; 30 | } 31 | } 32 | if (sy >= 1 && le >= 8 && up >= 1 && nu >= 1 && lo >= 1) { 33 | System.out.printf("----STRONG PASSWORD----"); 34 | } else if (le < 8) { 35 | System.out.printf("----NOT ENOUGH LENGTH----"); 36 | } else if (lo == 0) { 37 | System.out.printf("---DOESNOT CONTAINS LOWERCASE"); 38 | } else if (up == 0) { 39 | System.out.printf("---DOESNOT CONTAINS UPPERCASE"); 40 | } else if (nu == 0) { 41 | System.out.printf("---DOESNOT CONTAINS NUMERICVAL"); 42 | } else if (sy == 0) { 43 | System.out.printf("---DOESNOT CONTAINS SYMBOLS"); 44 | } else 45 | System.out.printf("----INVALID PASSWORD----"); 46 | 47 | } 48 | } 49 | 50 | import java.util.*; 51 | public class Hello { 52 | 53 | public static void main(String[] args) { 54 | //N columns Pattern 55 | Scanner sc=new Scanner(System.in); 56 | int a=sc.nextInt(); 57 | int[] ar=new int[a]; 58 | for(int i=0;i fa=new ArrayList<>(); 85 | ArrayList fc=new ArrayList<>(); 86 | Hello ello=new Hello(); 87 | for(int i=1;i<=num;i++){ 88 | if(num%i==0){ 89 | fa.add(i); 90 | fc.add(ello.co(i)); 91 | } 92 | } 93 | ello.sort(fa,fc); 94 | for(int i=0;i a,ArrayList b){ 104 | for(int i=0;imax){ 169 | max=s; 170 | maxIndex=i; 171 | } 172 | if(s