├── Area.java ├── Array concept.java ├── Ascending order of the number of occurrences of the word A.java ├── Counting Digits.java ├── Distinct Numbers.java ├── Factorial using recursion.java ├── Fibbo using recursion.java ├── Find First Repeating Character.java ├── Longest Substring with K Unique Characters.java ├── Longest Unique Substring.java ├── Make the Rows and col to Zero.java ├── Move Zeros to end without additional memory.java ├── Nothing in Common.java ├── Palindrom.java ├── Password and Username checking.java ├── Recursion basics.java ├── Remove Vowels has no repetation.java ├── Rverse in right in K postions.java ├── Rversing an array.java ├── Spiral Traverse of a Matrix.java ├── String operations.java ├── String positioning by Index in each word.java ├── Sum of Array elements(Recursion).java ├── Transpose.java(Matrix) ├── Words By its Pos at Last Index.java ├── all possible arrangements.java ├── countwords.java ├── number times charector.java ├── patterns.java ├── power using recursion.java ├── price.java (Maximum,Minimum) └── total.java /Area.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | class Area{ 3 | public static double area_circle(int r){ 4 | return r*r*3.14; 5 | } 6 | public static double area_rect(int l,int b){ 7 | return l*b; 8 | } 9 | public static double area_square(int a){ 10 | return a*a; 11 | } 12 | public static void main(String[] args){ 13 | Scanner sc = new Scanner(System.in); 14 | System.out.print("Enter the radius : "); 15 | int radius = sc.nextInt(); 16 | System.out.print("Enter the length : "); 17 | int len = sc.nextInt(); 18 | System.out.print("Enter the breadth : "); 19 | int bre = sc.nextInt(); 20 | System.out.print("Enter the length of square : "); 21 | int slen = sc.nextInt(); 22 | double ans1 = area_circle(radius); 23 | double ans2 = area_rect(len,bre); 24 | double ans3 = area_square(slen); 25 | System.out.println("The circle area is : "+ans1); 26 | System.out.println("The rectangle area is : "+ans2); 27 | System.out.println("The square area is : "+ans3); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Array concept.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class Main{ 3 | public static void main(String[] args){ 4 | int[] array = new int[5]; 5 | Scanner sc = new Scanner(System.in); 6 | for(int i=0;i<5;i++) 7 | { 8 | System.out.print("Enter the "+i+"th element : "); 9 | int a = sc.nextInt(); 10 | array[i] = a; 11 | } 12 | for(int i=0;i<5;i++) 13 | { 14 | System.out.println("The "+i+"th element : "+array[i]); 15 | } 16 | Arrays.sort(array); 17 | System.out.println("The array is : "+(Arrays.toString(array))); 18 | int[] arr = new int[10]; 19 | Arrays.fill(arr,7); 20 | int[] arr1 = new int[4]; 21 | arr1 = Arrays.copyOfRange(array,0,3); 22 | System.out.println("The array is : "+(Arrays.toString(arr))); 23 | System.out.println("The array is : "+(Arrays.toString(arr1))); 24 | System.out.println(Arrays.equals(arr,arr1)); 25 | int sum = Arrays.stream(array).sum(); 26 | System.out.println("The sum of "+(Arrays.toString(array))+" is "+sum); 27 | } 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /Ascending order of the number of occurrences of the word A.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class zoho{ 3 | public static void main(String[] args) { 4 | Scanner sc = new Scanner(System.in); 5 | int n = sc.nextInt(); 6 | String summa = sc.nextLine(); //Leave empty space in the Input!!! 7 | String search_word = sc.nextLine(); 8 | TreeMap> mp = new TreeMap<>(); 9 | for(int i=0;i new ArrayList<>()).add(str); 19 | } 20 | for (Map.Entry> u : mp.entrySet()) { 21 | for(String to_print : u.getValue()){ 22 | System.out.println(to_print); 23 | } 24 | } 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Counting Digits.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Main{ 3 | public static int digits(long n,int count){ 4 | if(n<=0) 5 | { 6 | return count; 7 | } 8 | count++; 9 | return digits(n/10,count); 10 | } 11 | public static void main(String[] args){ 12 | System.out.print("Enter the number : "); 13 | long n; 14 | Scanner sc = new Scanner(System.in); 15 | n = sc.nextInt(); 16 | int count = 0; 17 | long ans = digits(n,count); 18 | System.out.println("The digits in "+n+" is : "+ans); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Distinct Numbers.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | Scanner sc = new Scanner(System.in); 6 | int n = sc.nextInt(); 7 | Map mp = new LinkedHashMap<>(); 8 | for(int k=0;k u:mp.entrySet()) 14 | { 15 | count++; 16 | } 17 | System.out.println(count); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Factorial using recursion.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class Main{ 3 | public static long factorial(int n){ 4 | if(n<=0) 5 | { 6 | return 1; 7 | } 8 | return n*factorial(n-1); 9 | } 10 | public static void main(String[] args){ 11 | System.out.print("Enter the number to find the factorial : "); 12 | int n; 13 | Scanner sc = new Scanner(System.in); 14 | n = sc.nextInt(); 15 | long ans = factorial(n); 16 | System.out.println("The factorial of "+n+" is "+ans); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Fibbo using recursion.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class Main{ 3 | public static int[] fibbo(int n,int[] arr,int index){ 4 | if(n<=index) 5 | { 6 | return arr; 7 | } 8 | int num = arr[index-1] + arr[index-2]; 9 | arr[index] = num; 10 | return fibbo(n,arr,index+1); 11 | } 12 | public static void main(String[] args){ 13 | System.out.print("Enter the number of elements you need : "); 14 | int n; 15 | Scanner sc = new Scanner(System.in); 16 | n = sc.nextInt(); 17 | int[] arr = new int[n]; 18 | arr[0] = 0; 19 | arr[1] = 1; 20 | int index = 2; 21 | int[] ans = fibbo(n,arr,index); 22 | System.out.println("The Fibbo series with "+n+" elements is : "+Arrays.toString(ans)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Find First Repeating Character.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | Scanner sc = new Scanner(System.in); 6 | int n = sc.nextInt(); 7 | String p = sc.nextLine(); 8 | for(int k=0;k mp = new LinkedHashMap<>(); 12 | for(int i=0;i 1) 20 | { 21 | val = str.charAt(i); 22 | break; 23 | } 24 | } 25 | System.out.println(val); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Longest Substring with K Unique Characters.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class Main{ 3 | public static void main(String[] args) { 4 | Scanner sc = new Scanner(System.in); 5 | String str = sc.nextLine(); 6 | int k = sc.nextInt(); 7 | int left = 0; 8 | int right = 0; 9 | String result = ""; 10 | int maxLength = 0; 11 | Map map = new HashMap<>(); 12 | while(right < str.length()){ 13 | char ch = str.charAt(right); 14 | map.put(ch, map.getOrDefault(ch, 0)+1); 15 | while(map.size()>k){ 16 | char lef = str.charAt(left); 17 | map.put(lef,map.get(lef)-1); 18 | if(map.get(lef) == 0){ 19 | map.remove(lef); 20 | } 21 | left++; 22 | } 23 | if(right-left+1 > maxLength){ 24 | result = str.substring(left, right+1); 25 | maxLength = Math.max(result.length(),maxLength); 26 | } 27 | right++; 28 | } 29 | System.out.println(result+" -> "+maxLength); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Longest Unique Substring.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class ex { 3 | public static void main(String[] args) { 4 | Scanner sc = new Scanner(System.in); 5 | System.out.print("Enter the String : "); 6 | String str = sc.next(); 7 | int count = 0; 8 | int max = 1; 9 | HashMap map = new HashMap<>(); 10 | for(int i=0;i set = new HashSet<>(); 10 | Set set1 = new HashSet<>(); 11 | int n = sc.nextInt(); 12 | int m = sc.nextInt(); 13 | for(int j=0;j mp = new HashMap<>(); 8 | for(int i=0;i u:mp.entrySet()){ 13 | if(vowString.indexOf(u.getKey()) != -1 && u.getValue()==1){ 14 | toRemove += u.getKey(); 15 | } 16 | } 17 | String ans = ""; 18 | for(int i=0;i=left;i--) 45 | { 46 | System.out.print(matrix[bot][i] + " "); 47 | } 48 | bot--; 49 | } 50 | else if(d==4) 51 | { 52 | for(int i=bot;i>=top;i--) 53 | { 54 | System.out.print(matrix[i][left] + " "); 55 | } 56 | left++; 57 | } 58 | d++; 59 | if(d==5) 60 | { 61 | d=1; 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /String operations.java: -------------------------------------------------------------------------------- 1 | import java.util.*; //INCLUDES ALL THE FILES 2 | class Main{ 3 | public static void main(String[] args){ 4 | Scanner sc = new Scanner(System.in); 5 | StringBuilder str = new StringBuilder(); 6 | str.append("Hello"); 7 | str.append(" World"); 8 | System.out.println("The String after appending is : "+str); 9 | str.replace(5,6," to the "); 10 | System.out.println("The String after Replacing is : "+str); 11 | str.delete(1,3); 12 | System.out.println("The String after Deleting is : "+str); 13 | str.reverse(); 14 | System.out.println("The String after Reversing is : "+str); 15 | System.out.println("The String capacity is : "+(str.capacity())); 16 | System.out.println("==========String Builder up======="); 17 | System.out.println(" "); 18 | System.out.println("==========Strings down============"); 19 | String str1 = " Normal String "; 20 | System.out.println("The String Length is : "+(str1.length())); 21 | System.out.println("The indexOf operation : "+(str1.indexOf('S'))); 22 | System.out.println("The charAt operation : "+(str1.charAt(4))); 23 | String str2 = "String"; 24 | System.out.println("The compare operation : "+(str2.compareTo("sTRING"))); 25 | System.out.println("The compare without case operation : "+(str2.compareToIgnoreCase("string"))); 26 | System.out.println("The contains operation : "+(str1.contains("mal "))); 27 | System.out.println("The endwith operation : "+(str1.endsWith("g "))); 28 | System.out.println("The replace operation : "+(str1.replace("String ","Programming is Java"))); 29 | System.out.println("The replaceall operation : "+(str1.replaceAll(" ","@!"))); 30 | System.out.println("The replace first operation : "+(str1.replaceFirst("[N]","\\$"))); 31 | System.out.println("The lower case operation : "+(str1.toLowerCase())); 32 | System.out.println("The upper case operation : "+(str1.toUpperCase())); 33 | System.out.println("The trim operation : "+(str1.trim())); 34 | System.out.println("The number to string : "+(String.valueOf(123456789))); 35 | char[] array = str1.toCharArray(); 36 | System.out.println("The character array is : "+(Arrays.toString(array))); 37 | System.out.print("The Number of Vowel letters are : "); 38 | int vow = 0; 39 | int con = 0; 40 | for(char u :str1.toCharArray()) 41 | { 42 | if("AEIOUaeiou".indexOf(u) != -1) 43 | { 44 | vow++; 45 | } 46 | else if("AEIOUaeiou".indexOf(u) == -1 && u!=' ') 47 | { 48 | con++; 49 | } 50 | } 51 | System.out.println(vow); 52 | System.out.print("The Number of Consonents is : "); 53 | System.out.println(con); 54 | System.out.println("The substring operation is : "+(str1.substring(7,15))); 55 | System.out.println("The substring operation is : "+(str1.substring(7))); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /String positioning by Index in each word.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class zoho{ 3 | public static void main(String[] args) { 4 | Scanner sc = new Scanner(System.in); 5 | String str = sc.nextLine(); 6 | int words = 0; 7 | for(int i=0;i aabbb 13 | String temp = ""; // 10a3b -> aaaaaaaaaabbb 14 | for(int j=0;j=1;j--) 17 | { 18 | System.out.print(" "); 19 | } 20 | for(int j=1;j<=i;j++) 21 | { 22 | System.out.print("*"); 23 | } 24 | for(int j=i-1;j>=1;j--) 25 | { 26 | System.out.print("*"); 27 | } 28 | System.out.println(" "); 29 | } 30 | } 31 | public static void inverted_triangle(int c){ 32 | for(int i=c;i>=1;i--) 33 | { 34 | for(int j=c-i;j>=1;j--) 35 | { 36 | System.out.print(" "); 37 | } 38 | for(int j=1;j<=i;j++) 39 | { 40 | System.out.print("*"); 41 | } 42 | for(int j=i-1;j>=1;j--) 43 | { 44 | System.out.print("*"); 45 | } 46 | System.out.println(" "); 47 | } 48 | } 49 | public static void reverse_triangle(int d){ 50 | for(int i=d;i>=1;i--) 51 | { 52 | for(int j=i;j>=1;j--) 53 | { 54 | System.out.print("*"); 55 | } 56 | System.out.println(" "); 57 | } 58 | } 59 | public static void main(String[] args){ 60 | Scanner sc = new Scanner(System.in); 61 | while(true) 62 | { 63 | System.out.println("========Pattern Menu========"); 64 | System.out.println("1.Square Pattern."); 65 | System.out.println("2.Triangle Pattern."); 66 | System.out.println("3.Inverted Triangle Pattern."); 67 | System.out.println("4.Reverse Triangle Pattern."); 68 | System.out.println("5.Exit"); 69 | System.out.print("Enter the Choice : "); 70 | int choice = sc.nextInt(); 71 | if(choice == 1) 72 | { 73 | System.out.print("Enter the number of side you need in square : "); 74 | int n = sc.nextInt(); 75 | square(n); 76 | } 77 | else if(choice == 2) 78 | { 79 | System.out.print("Enter the height of the triangle : "); 80 | int n = sc.nextInt(); 81 | triangle(n); 82 | } 83 | else if(choice == 3) 84 | { 85 | System.out.print("Enter the height of the Inverted triangle : "); 86 | int n = sc.nextInt(); 87 | inverted_triangle(n); 88 | } 89 | else if(choice == 4) 90 | { 91 | System.out.print("Enter the height of the Reverse triangle : "); 92 | int n = sc.nextInt(); 93 | reverse_triangle(n); 94 | } 95 | else if(choice == 5) 96 | { 97 | break; 98 | } 99 | else 100 | { 101 | System.out.print("Entered wrong choice!!!!...Enter the Correct choice"); 102 | } 103 | } 104 | System.out.print("The patterns are Succesfully Executed!!!"); 105 | } 106 | } 107 | 108 | -------------------------------------------------------------------------------- /power using recursion.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class Main{ 3 | public static long power(long n,int p){ 4 | if(p<=0) 5 | { 6 | return 1; 7 | } 8 | return n*power(n,p-1); 9 | } 10 | public static void main(String[] args){ 11 | System.out.print("Enter the base : "); 12 | long n; 13 | Scanner sc = new Scanner(System.in); 14 | n = sc.nextInt(); 15 | System.out.print("Enter the power : "); 16 | int p = sc.nextInt(); 17 | long ans = power(n,p); 18 | System.out.println("The power of "+p+" to the base "+n+" is : "+ans); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /price.java (Maximum,Minimum): -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class price{ 3 | public static void main(String[] args){ 4 | int[] arr = new int[7]; 5 | String[] day = {"Monday","Tuesday","Wednesday","Thurday","Friday","Saturday","Sunday"}; 6 | Scanner sc = new Scanner(System.in); 7 | for(int i=0;i<7;i++) 8 | { 9 | System.out.print("Enter the "+(i+1)+"th day sales : "); 10 | int a = sc.nextInt(); 11 | arr[i] = a; 12 | } 13 | int max = arr[0]; 14 | int min = arr[0]; 15 | int maxindex = 0; 16 | int minindex = 0; 17 | for(int i=0;i<7;i++) 18 | { 19 | if(arr[i]>max) 20 | { 21 | max = arr[i]; 22 | maxindex = i; 23 | } 24 | else if(arr[i]