Flowcharts
Backtracking
Variables & Data Types in Java
Time & Space Complexity
Operators
ArrayLists
if-else Statements
Linked Lists
Flow Control (Loops)
Stacks
Patterns
Queues
Functions & Methods
Greedy Algorithms
Arrays
Binary Trees
Sorting Algorithms
Binary Search Trees
2D Arrays
Heaps/Priority Queues
Strings
Hashing
Bit Manipulation
Tries
OOPs
Graphs
Recursion
Dynamic Programming
Divide & Conquer
Segment Trees
Backtracking
Variables & Data Types in Java
Time & Space Complexity
Operators
ArrayLists
if-else Statements
Linked Lists
Flow Control (Loops)
Stacks
Patterns
Queues
Functions & Methods
Greedy Algorithms
Arrays
Binary Trees
Sorting Algorithms
Binary Search Trees
2D Arrays
Heaps/Priority Queues
Strings
Hashing
Bit Manipulation
Tries
OOPs
Graphs
Recursion
Dynamic Programming
Divide & Conquer
Segment Trees
👍1
package com.Aman;public class Mainmeh { public static void main(Integer args){System.out.println("method 1");} public static void main(char args){ System.out.println("method 1"); } public static void main(String ... args){ System.out.println("method 1"); } public static void main(long args){System.out.println("method 1");} public static void main(double args){ System.out.println("method 1"); } public static void main(float ... args){ System.out.println("method 1"); }}public class SpecialCase1 { public static void main(String...args){ int k =1 ; for(int i = 1; i<=5;i++){ for(int j = 1; j<=5;j++){ System.out.print(k++%10); } System.out.println(); } }}public class ArmstrongNo1 { public static void main(String[] arg) { int i = 1, arm; System.out.println("Armstrong numbers between 100 to 999"); while (i < 1000) { arm = armstrongOrNot(i); if (arm == i) System.out.println(i); i++; } } static int armstrongOrNot(int num) { int x, a = 0; while (num != 0) { x = num % 10; a = a + (x * x * x); num /= 10; } return a; }}import java.util.*;public class ArmstrongNo2 { public static void main(String[] arg) { int a, arm = 0, n, temp; Scanner sc = new Scanner(System.in); System.out.println("Enter a number"); n = sc.nextInt(); temp = n; for (; n != 0; n /= 10) { a = n % 10; arm = arm + (a * a * a); } if (arm == temp) System.out.println(temp + " is a armstrong number "); else System.out.println(temp + " is not a armstrong number "); }}//import java.util.*;//import static java.awt.font.NumericShaper.search;public class Q24_1 { public static void main(String[] args) { // Scanner x = new Scanner(System.in); //System.out.println(" enter 10 Digits ");// int[] arr = new int[10];// for (int i : arr) {// arr[i] = x.nextInt(); int[] arr = {5, 6, 8, 9, 2, 4, 6, 1}; int toFind = 5; boolean found = search(arr, toFind); if (found) System.out.println(toFind + " is found"); else System.out.println(toFind + " is not found"); } /* * A method to search toFind in arr * arr: the array to search * toFind: the element to search */ public static boolean search(int[] arr, int toFind) { int left = 0; int right = arr.length - 1; while (left <= right) { int mid = (left + right) / 2; if (arr[mid] == toFind) { return true; } else if (arr[mid] < toFind) { left = mid + 1; } else { right = mid - 1; } } return false; }}public class Q25_1 { public static void main(String[] args) { int[] arr = {5, 6, 8, 9, 2, 4, 6, 1}; int left = 0, right = arr.length - 1; while (left < right) { while (arr[left] % 2 == 0 && left < right) left++; while (arr[right] % 2 == 1 && left < right) right--; if (left < right) { int temp = arr[left]; arr[left] = arr[right]; arr[right] = temp; left++; right--; } } System.out.println("Even numbers on left side and Odd numbers on right side: "); for (int j : arr) System.out.print(j + " ");// for (int i = 0; i < arr.length; i++)// System.out.print(arr[i] + " "); }}public class Q26_1 { public static void main(String[] args) { int[]arr = {5,6,8,9,2,4,6,1}; int largest = arr[0]; int secondLargest = arr[0]; System.out.println("The given array is:"); for (int k : arr) { System.out.print(k + "\t"); } for (int j : arr) { if (j > largest) { secondLargest = largest; largest = j; } else if (j > secondLargest) { secondLargest = j; } } System.out.print("Second largest number is:" + secondLargest); }}public class Q29_1 { static void printAllSubsets(int[] A, int K) { int N = A.length; for (int i = 0; i < (1 << N); i++) { int sum = 0; for (int j = 0; j < N; j++) { if ((i & (1 << j)) > 0) sum += A[j]; } if (sum == K) { for (int j = 0; j < N; j++) { if ((i & (1 << j)) > 0) System.out.print(A[j] + " "); } System.out.println(); } } } public static void main(String[] args) { int[] A = {0, 1, 2, 3, 5, 6, 7, 11, 12, 14, 20}; int K = 5; printAllSubsets(A, K); }}public class Q29_2 { public static void main(String[] args) { int[] a = {0, 1, 2, 3, 5, 6, 7, 11, 12, 14, 20}; int n = 5; for (int i = 0; i < a.length; i++) { for (int j = 0; j < a.length; j++) { if ((a[i] + a[j]) == n) { System.out.println("[" + i + "," + j + "]"); } } } }}package com.Aman;public class Q27_1 { static int maxConsecutiveOnes(int x){ int count = 0; while (x!=0) { x = (x & (x << 1)); count++; } return count; } public static void main(String[] args) { int x = 10000; System.out.println(maxConsecutiveOnes(x)); }}