├── QN_01_Harshitha.java ├── QN_02_Harshitha.java ├── QN_03_Harshitha.java ├── QN_04_Harshitha.java ├── QN_05_Harshitha.java ├── QN_06_Harshitha.java ├── QN_11_Hariharan.java ├── QN_11_Harshitha.java ├── QN_11_Krishna.java ├── QN_12_Krishna.java ├── QN_14_Harshitha.java ├── QN_16_SOWMIYA.py ├── QN_18_Harshitha.java ├── QN_1_AMUTHAN.java ├── QN_1_Krishna.java ├── QN_1_ROHAN.py ├── QN_1_sriswasthika.java ├── QN_21_Harshitha.java ├── QN_23_Hariharan.java ├── QN_23_Harshitha.java ├── QN_23_Vicky.py ├── QN_24_Harshitha.java ├── QN_25_Harshitha.java ├── QN_2_Atchayah-S.java ├── QN_2_ROHAN.py ├── QN_30_SRIRAM.java ├── QN_3_AMUTHAN.Java ├── QN_3_Atchayah-S.java ├── QN_3_ROHAN.py ├── QN_43_Hariharan.java ├── QN_4_Atchayah-S.java ├── QN_4_ROHAN.py ├── QN_52_SRIRAM.java ├── QN_53_AMUTHAN.java ├── QN_53_Hariharan.java ├── QN_53_Krishna.java ├── QN_5_Atchayah-S.java ├── QN_5_ROHAN.py ├── QN_61_SRIRAM.java ├── QN_62_SRIRAM.java ├── QN_63_SRIRAM.java ├── QN_64_SRIRAM.java ├── QN_65_SRIRAM.java ├── QN_6_Krish.java ├── QN_6_ROHAN.py ├── QN_7_ROHAN.py ├── QN_8_Atchayah-S.java ├── QN_8_ROHAN.py ├── QN_9_ROHAN.py ├── Q_1_AMUTHAN.java ├── Q_2_AMUTHAN.java ├── Qn_1_Abhilash.java ├── Qn_1_Arularasan.java └── README.md /QN_01_Harshitha.java: -------------------------------------------------------------------------------- 1 | Math-Based Problems 2 | Find the factorial of a number using recursion. 3 | 4 | 5 | 6 | 7 | // Online Java Compiler 8 | // Use this editor to write, compile and run your Java code online 9 | import java.util.*; 10 | class Main { 11 | public static void main(String[] args) { 12 | Scanner sc=new Scanner(System.in); 13 | int n=sc.nextInt(); 14 | System.out.println(Fact(n)); 15 | } 16 | 17 | public static int Fact(int n){ 18 | if(n<=1){ 19 | return 1; 20 | } 21 | else{ 22 | return n * Fact(n-1); 23 | } 24 | } 25 | } 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /QN_02_Harshitha.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class prime{ 3 | public static void main(String[] args){ 4 | Scanner sc=new Scanner(System.in); 5 | boolean flag=false; 6 | int num=sc.nextInt(); 7 | if(num<=1) 8 | flag=true; 9 | else{ 10 | for(int i=2;ib) 10 | min=b; 11 | else 12 | min=a; 13 | for(int i=min;i>=1;i--){ 14 | if(a%i==0 && b%i==0){ 15 | gcd=i; 16 | break; 17 | } 18 | } 19 | System.out.print(gcd); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /QN_05_Harshitha.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class palindrome{ 3 | public static void main(String[] args){ 4 | Scanner sc=new Scanner(System.in); 5 | int n=sc.nextInt(); 6 | int sum=0,temp=n; 7 | while(n>0){ 8 | int dig=n%10; 9 | sum=(sum*10)+dig; 10 | n/=10; 11 | } 12 | if(temp==sum) 13 | System.out.print("Palindrome"); 14 | else 15 | System.out.print("Not Palindrome"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /QN_06_Harshitha.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class count{ 3 | public static void main(String[] args){ 4 | Scanner sc=new Scanner(System.in); 5 | int n=sc.nextInt(); 6 | int sol=0; 7 | while(n>0){ 8 | int dig=n%10; 9 | sol+=1; 10 | n/=10; 11 | } 12 | System.out.print(sol); 13 | } 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /QN_11_Hariharan.java: -------------------------------------------------------------------------------- 1 | public class main { 2 | public static String reverseString(String s) { 3 | char[] chars = s.toCharArray(); 4 | int l = 0; 5 | int r = chars.length - 1; 6 | 7 | while (l < r) { 8 | char temp = chars[l]; 9 | chars[l] = chars[r]; 10 | chars[r] = temp; 11 | 12 | l++; 13 | r--; 14 | } 15 | return new String(chars); 16 | } 17 | -------------------------------------------------------------------------------- /QN_11_Harshitha.java: -------------------------------------------------------------------------------- 1 | 11. REVERSE STRING 2 | 3 | import java.util.*; 4 | class reverse{ 5 | public static void main(String[] args){ 6 | Scanner sc=new Scanner(System.in); 7 | String str=sc.nextLine(); 8 | char a[]=str.toCharArray(); 9 | 10 | int left=0; 11 | int right=a.length-1; 12 | while(leftmax){ 17 | max=a[i]; 18 | } 19 | } 20 | System.out.println("min: "+min); 21 | System.out.println("max: "+max); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /QN_23_Hariharan.java: -------------------------------------------------------------------------------- 1 | class main 2 | { 3 | public static void main (String[] args) 4 | { 5 | Scanner sc=new Scanner(System.in); 6 | int n=sc.nextInt(); 7 | int[] a=new int[n]; 8 | for(int i=0;imax){ 14 | max=a[i]; 15 | } 16 | } 17 | int secmax= Integer.MIN_VALUE; 18 | for(int i=0;i one): 12 | second = one 13 | one = lst[i] 14 | elif(second < lst[i] < one): 15 | second = lst[i] 16 | 17 | if (one == second): 18 | return -1 19 | 20 | return second -------------------------------------------------------------------------------- /QN_24_Harshitha.java: -------------------------------------------------------------------------------- 1 | // Online Java Compiler 2 | // Use this editor to write, compile and run your Java code online 3 | import java.util.*; 4 | class Main { 5 | public static void main(String[] args) { 6 | Scanner sc=new Scanner(System.in); 7 | int count=0; 8 | int n=sc.nextInt(); 9 | int a[]=new int[n]; 10 | for(int i=0;i0) 20 | System.out.println("Array contains duplicate values"); 21 | else 22 | System.out.println("Array doesn't contain any duplicate values"); 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /QN_25_Harshitha.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | 3 | Online Java Compiler. 4 | Code, Compile, Run and Debug java program online. 5 | Write your code in this editor and press "Run" button to execute it. 6 | 7 | *******************************************************************************/ 8 | import java.util.*; 9 | public class Main 10 | { 11 | public static void main(String[] args) { 12 | Scanner sc=new Scanner(System.in); 13 | int n=sc.nextInt(); 14 | int a[]=new int[n]; 15 | for(int i=0;i0){ 6 | if(num1%result==0 && num2%result==0) 7 | break; 8 | result--; 9 | } 10 | return result; 11 | } 12 | public static void main(String args[]){ 13 | int num1, num2; 14 | Scanner sc=new Scanner(System.in); 15 | num1=sc.nextInt(); 16 | num2=sc.nextInt(); 17 | System.out.println("GCD of "+num1+" and "+num2+" is "+gcd(num1,num2)); 18 | } 19 | } -------------------------------------------------------------------------------- /QN_4_ROHAN.py: -------------------------------------------------------------------------------- 1 | a = 24 2 | b = 56 3 | 4 | # Recursive solution : TC - O(log(min(a, b))) , SC - O(log(min(a, b))) 5 | def recursive_gcd(a, b): 6 | if b == 0: 7 | return a 8 | return recursive_gcd(b, a % b) 9 | 10 | print(recursive_gcd(a, b)) 11 | 12 | 13 | # Iterative solution : TC - O(log(min(a, b))) , SC - O(1) 14 | def euclid_gcd(a,b): 15 | while b != 0: 16 | a, b = b, a % b 17 | return a 18 | 19 | print(euclid_gcd(a, b)) 20 | -------------------------------------------------------------------------------- /QN_52_SRIRAM.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public static void main(String args[]) 3 | { 4 | int n=125; 5 | int count = hammingWeight(n); 6 | System.out.println(count); 7 | } 8 | 9 | public static int hammingWeight(int n) { 10 | int a=0; 11 | while(n>0) 12 | { 13 | if(n%2==1) a+=1; 14 | n/=2; 15 | } 16 | return a; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /QN_53_AMUTHAN.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Solution { 3 | public static boolean isPowerOfTwo(int n) { 4 | return (n>0) && ((n & (n-1)) == 0); 5 | } 6 | public static void main(String args[]) { 7 | Scanner sc = new Scanner(System.in); 8 | int n = sc.nextInt(); 9 | System.out.println(isPowerOfTwo(n)); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /QN_53_Hariharan.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public boolean isPowerOfTwo(int n) { 3 | if(n==0 || n==Integer.MIN_VALUE){ 4 | return false; 5 | } 6 | return (n & (n-1))==0; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /QN_53_Krishna.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public boolean isPowerOfTwo(int n) { 3 | if(n<=0) return false; // edge case for negative numbers 4 | 5 | //by consecutive dividing by 2; 6 | // while(n%2==0){ 7 | // n/=2; 8 | // } 9 | // return n==1; 10 | 11 | // using right shift 12 | // while(n%2==0){ 13 | // n>>=1; 14 | // } 15 | // return n==1; 16 | 17 | //8&(8-1) ... 8&7==0 ... 1000&0111==0... it will be power of two.. 18 | return (n&(n-1))==0; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /QN_5_Atchayah-S.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class PalindromeNumber{ 3 | public static void main(String[] args){ 4 | int num,temp,rem,rev=0; 5 | Scanner sc=new Scanner(System.in); 6 | num=sc.nextInt(); 7 | temp=num; 8 | while(num>0){ 9 | rem=num%10; 10 | rev=rev*10+rem; 11 | num/=10; 12 | } 13 | if(temp==rev){ 14 | System.out.println(temp+" is a palindrome number."); 15 | } 16 | else{ 17 | System.out.println(temp+" is not a palindrome number."); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /QN_5_ROHAN.py: -------------------------------------------------------------------------------- 1 | n = 12321 2 | 3 | # Standard method - stores every digits in an list and checks the list 4 | def isPalindrome(n): 5 | stk = [] 6 | while n: 7 | stk.append(n % 10) 8 | n //= 10 9 | low = 0 10 | high = len(stk) - 1 11 | while low < high: 12 | if stk[low] != stk[high]: 13 | return False 14 | low += 1 15 | high -= 1 16 | return True 17 | 18 | print(isPalindrome(n)) 19 | 20 | # One Liner 21 | print(str(n) == str(n)[::-1]) 22 | -------------------------------------------------------------------------------- /QN_61_SRIRAM.java: -------------------------------------------------------------------------------- 1 | public class BinarySearch { 2 | public static int binarySearch(int[] arr, int target) { 3 | int left = 0, right = arr.length - 1; 4 | 5 | while (left <= right) { 6 | int mid = left + (right - left) / 2; 7 | 8 | if (arr[mid] == target) 9 | return mid; 10 | else if (arr[mid] < target) 11 | left = mid + 1; 12 | else 13 | right = mid - 1; 14 | } 15 | return -1; // not found 16 | } 17 | 18 | public static void main(String[] args) { 19 | int[] arr = {2, 4, 6, 8, 10, 12}; 20 | int target = 10; 21 | int result = binarySearch(arr, target); 22 | System.out.println(result != -1 ? "Found at index " + result : "Not found"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /QN_62_SRIRAM.java: -------------------------------------------------------------------------------- 1 | public class SelectionSort { 2 | public static void selectionSort(int[] arr) { 3 | for (int i = 0; i < arr.length - 1; i++) { 4 | int minIdx = i; 5 | for (int j = i + 1; j < arr.length; j++) { 6 | if (arr[j] < arr[minIdx]) { 7 | minIdx = j; 8 | } 9 | } 10 | // swap 11 | int temp = arr[i]; 12 | arr[i] = arr[minIdx]; 13 | arr[minIdx] = temp; 14 | } 15 | } 16 | 17 | public static void main(String[] args) { 18 | int[] arr = {64, 25, 12, 22, 11}; 19 | selectionSort(arr); 20 | for (int num : arr) System.out.print(num + " "); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /QN_63_SRIRAM.java: -------------------------------------------------------------------------------- 1 | public class BubbleSort { 2 | public static void bubbleSort(int[] arr) { 3 | for (int i = 0; i < arr.length - 1; i++) { 4 | boolean swapped = false; 5 | for (int j = 0; j < arr.length - 1 - i; j++) { 6 | if (arr[j] > arr[j + 1]) { 7 | // swap 8 | int temp = arr[j]; 9 | arr[j] = arr[j + 1]; 10 | arr[j + 1] = temp; 11 | swapped = true; 12 | } 13 | } 14 | if (!swapped) break; // optimization 15 | } 16 | } 17 | 18 | public static void main(String[] args) { 19 | int[] arr = {5, 1, 4, 2, 8}; 20 | bubbleSort(arr); 21 | for (int num : arr) System.out.print(num + " "); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /QN_64_SRIRAM.java: -------------------------------------------------------------------------------- 1 | public class MergeSort { 2 | public static void mergeSort(int[] arr, int left, int right) { 3 | if (left < right) { 4 | int mid = (left + right) / 2; 5 | 6 | mergeSort(arr, left, mid); 7 | mergeSort(arr, mid + 1, right); 8 | 9 | merge(arr, left, mid, right); 10 | } 11 | } 12 | 13 | private static void merge(int[] arr, int left, int mid, int right) { 14 | int n1 = mid - left + 1; 15 | int n2 = right - mid; 16 | 17 | int[] L = new int[n1]; 18 | int[] R = new int[n2]; 19 | 20 | for (int i = 0; i < n1; i++) L[i] = arr[left + i]; 21 | for (int j = 0; j < n2; j++) R[j] = arr[mid + 1 + j]; 22 | 23 | int i = 0, j = 0, k = left; 24 | 25 | while (i < n1 && j < n2) { 26 | if (L[i] <= R[j]) arr[k++] = L[i++]; 27 | else arr[k++] = R[j++]; 28 | } 29 | 30 | while (i < n1) arr[k++] = L[i++]; 31 | while (j < n2) arr[k++] = R[j++]; 32 | } 33 | 34 | public static void main(String[] args) { 35 | int[] arr = {38, 27, 43, 3, 9, 82, 10}; 36 | mergeSort(arr, 0, arr.length - 1); 37 | for (int num : arr) System.out.print(num + " "); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /QN_65_SRIRAM.java: -------------------------------------------------------------------------------- 1 | public class QuickSort { 2 | public static void quickSort(int[] arr, int low, int high) { 3 | if (low < high) { 4 | int pi = partition(arr, low, high); 5 | 6 | quickSort(arr, low, pi - 1); 7 | quickSort(arr, pi + 1, high); 8 | } 9 | } 10 | 11 | private static int partition(int[] arr, int low, int high) { 12 | int pivot = arr[high]; 13 | int i = low - 1; 14 | 15 | for (int j = low; j < high; j++) { 16 | if (arr[j] <= pivot) { 17 | i++; 18 | // swap 19 | int temp = arr[i]; 20 | arr[i] = arr[j]; 21 | arr[j] = temp; 22 | } 23 | } 24 | 25 | // swap pivot 26 | int temp = arr[i + 1]; 27 | arr[i + 1] = arr[high]; 28 | arr[high] = temp; 29 | 30 | return i + 1; 31 | } 32 | 33 | public static void main(String[] args) { 34 | int[] arr = {10, 7, 8, 9, 1, 5}; 35 | quickSort(arr, 0, arr.length - 1); 36 | for (int num : arr) System.out.print(num + " "); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /QN_6_Krish.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | //Count no of digits in a Number 6 | //Using Math 7 | int num=1009; 8 | System.out.println((int)Math.log10(num)+1);//op 4 9 | //while loop 10 | int count =0; 11 | while(num>0){ 12 | num/=10; 13 | count++; 14 | } 15 | System.out.println(count); 16 | num=1009; 17 | //Inbuild Function Using String length 18 | System.out.println((num+"").length()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /QN_6_ROHAN.py: -------------------------------------------------------------------------------- 1 | n = 12345 2 | 3 | # Standard method - counts digit by digit 4 | def numberLength(n): 5 | cnt = 0 6 | while n: 7 | cnt += 1 8 | n //= 10 9 | return cnt 10 | 11 | print(numberLength(n)) 12 | 13 | # One Liner 14 | print(len(str(n))) 15 | -------------------------------------------------------------------------------- /QN_7_ROHAN.py: -------------------------------------------------------------------------------- 1 | num = 12340 2 | 3 | # Standard method - iterates digit by digit 4 | def reverseNumber(num): 5 | new_num = 0 6 | while num: 7 | new_num = new_num * 10 + (num % 10) 8 | num //= 10 9 | return new_num 10 | 11 | print(reverseNumber(num)) 12 | 13 | # One Liner 14 | print(int(str(num)[::-1])) 15 | -------------------------------------------------------------------------------- /QN_8_Atchayah-S.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class AmstrongNumber{ 3 | public static boolean isAmstrong(int num){ 4 | int temp=num,len=0,result=0; 5 | while(temp>0){ 6 | temp/=10; 7 | len++; 8 | } 9 | temp=num; 10 | while(temp>0){ 11 | result+=Math.pow(temp%10,len); 12 | temp/=10; 13 | } 14 | return (result==num); 15 | } 16 | public static void main(String args[]){ 17 | int num; 18 | Scanner sc=new Scanner(System.in); 19 | num=sc.nextInt(); 20 | System.out.println(isAmstrong(num)?num+" is an Armstrong Number": num+" is not an Armstrong Number"); 21 | } 22 | } -------------------------------------------------------------------------------- /QN_8_ROHAN.py: -------------------------------------------------------------------------------- 1 | num = 153 2 | 3 | # Standard method - iterates digit by digit 4 | def armstrongNumber(num): 5 | sum_of_cubes = 0 6 | n = num 7 | while num: 8 | digit = num % 10 9 | sum_of_cubes += digit ** 3 10 | num //= 10 11 | return sum_of_cubes == n 12 | 13 | print(armstrongNumber(num)) 14 | 15 | # One Liner 16 | print(sum(int(digit) ** 3 for digit in str(num)) == num) 17 | -------------------------------------------------------------------------------- /QN_9_ROHAN.py: -------------------------------------------------------------------------------- 1 | #Best and quickest Prime check - TC - O(n), SC - O(n) 2 | def isPrime(n): 3 | if n < 2: 4 | return False 5 | if n < 4: return True 6 | if n % 2 == 0 or n % 3 == 0: 7 | return False 8 | for i in range(5, int(n ** 0.5) + 1, 6): 9 | if n % i == 0 or n % (i + 2) == 0: 10 | return False 11 | return True 12 | 13 | n = 100 14 | for i in range(n + 1): 15 | if isPrime(i): 16 | print(i, end = ' ') 17 | -------------------------------------------------------------------------------- /Q_1_AMUTHAN.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class FactorialUsingRecursion { 3 | public static int recursion(int n) { 4 | if(n-1 == 0) { 5 | return 1; 6 | } 7 | return n * recursion(n-1); 8 | } 9 | public static void main (String args[]) { 10 | Scanner sc = new Scanner(System.in); 11 | int n = sc.nextInt(); 12 | int answer = recursion(n); 13 | System.out.print("The factorial of "+n+" is "+answer); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Q_2_AMUTHAN.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class PrimeNumberChecker { 3 | public static boolean isPrime(int n) { 4 | if(n == 1 || n == 0) { 5 | return false; 6 | }else if(n == 2) { 7 | return true; 8 | } 9 | int c = 1; 10 | for(int i=2; i<=n/2; i++) { 11 | if(n %% i == 0) { 12 | c = 0; 13 | } 14 | } 15 | if(c == 1) { 16 | return true; 17 | }else { 18 | return false; 19 | } 20 | } 21 | public static void main (String args[]) { 22 | Scanner sc = new Scanner(System.in); 23 | int n = sc.nextInt(); 24 | if(isPrime(n)) { 25 | System.out.println(n+" is prime number"); 26 | }else { 27 | System.out.println(n+" is not prime number"); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Qn_1_Abhilash.java: -------------------------------------------------------------------------------- 1 | class Fact_rec{ 2 | static int factorial(int n) { 3 | if (n == 0) 4 | return 1; 5 | else 6 | return (n * factorial(n - 1)); 7 | } 8 | public static void main(String args[]){ 9 | int num=4; 10 | int fact=factorial(num); 11 | System.out.println("factorial of "+num+" is "+fact); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Qn_1_Arularasan.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Main{ 3 | public static void main(String[] args){ 4 | int a=3; 5 | System.out.print(factorial(a));//3*2*1 = 6 6 | } 7 | public static int factorial(int a){ 8 | if(a==0) return 1; 9 | return a*factorial(a-1); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 75 Logic Building Problems 2 | 3 | This repository contains a curated list of **75 logic-building problems** designed to enhance your problem-solving skills. Each problem is categorized into different topics such as math, strings, arrays, recursion, puzzles, and more. Feel free to attempt the problems and explore the solutions. 4 | 5 | --- 6 | 7 | ## Math-Based Problems 8 | 9 | 1. Find the factorial of a number using recursion. 10 | 2. Check if a number is prime. 11 | 3. Generate the first N Fibonacci numbers. 12 | 4. Find the greatest common divisor (GCD) of two numbers. 13 | 5. Check if a number is a palindrome. 14 | 6. Count the number of digits in a number. 15 | 7. Reverse the digits of a number. 16 | 8. Check if a number is an Armstrong number. 17 | 9. Print all prime numbers up to N. 18 | 10. Find the sum of digits of a number until it becomes a single digit. 19 | 20 | --- 21 | 22 | ## String Manipulation 23 | 24 | 11. Reverse a string. 25 | 12. Check if a string is a palindrome. 26 | 13. Find the frequency of characters in a string. 27 | 14. Remove all vowels from a string. 28 | 15. Replace spaces with underscores in a string. 29 | 16. Count the number of words in a string. 30 | 17. Find the longest word in a string. 31 | 18. Check if two strings are anagrams. 32 | 19. Remove duplicate characters from a string. 33 | 20. Find the first non-repeating character in a string. 34 | 35 | --- 36 | 37 | ## Array Problems 38 | 39 | 21. Find the largest and smallest element in an array. 40 | 22. Sort an array without using in-built functions. 41 | 23. Find the second largest number in an array. 42 | 24. Remove duplicate elements from an array. 43 | 25. Rotate an array to the right by K steps. 44 | 26. Merge two sorted arrays. 45 | 27. Find the missing number in an array of size N containing numbers from 1 to N+1. 46 | 28. Find the intersection of two arrays. 47 | 29. Find the subarray with the maximum sum (Kadane’s algorithm). 48 | 30. Move all zeros in an array to the end. 49 | 50 | --- 51 | 52 | ## Recursion Problems 53 | 54 | 31. Find the Nth Fibonacci number using recursion. 55 | 32. Solve the Tower of Hanoi problem. 56 | 33. Print all subsets of a given set. 57 | 34. Calculate the power of a number using recursion. 58 | 35. Generate all permutations of a string. 59 | 36. Solve the N-Queens problem. 60 | 37. Find the sum of the first N natural numbers using recursion. 61 | 38. Count the number of ways to climb stairs (1 or 2 steps at a time). 62 | 39. Find the greatest common divisor (GCD) using recursion. 63 | 40. Print all possible combinations of balanced parentheses. 64 | 65 | --- 66 | 67 | ## Logical Puzzles 68 | 69 | 41. Solve the classic FizzBuzz problem. 70 | 42. Check if a number is a perfect square. 71 | 43. Determine if a year is a leap year. 72 | 44. Simulate the Josephus problem. 73 | 45. Check if a Sudoku board is valid. 74 | 46. Calculate the digital root of a number. 75 | 47. Find the day of the week for a given date. 76 | 48. Solve the classic “Rat in a Maze” problem. 77 | 49. Find the longest common prefix among a list of strings. 78 | 50. Generate Pascal’s Triangle. 79 | 80 | --- 81 | 82 | ## Bit Manipulation 83 | 84 | 51. Find the only non-repeating element in an array where every other element repeats twice. 85 | 52. Count the number of 1s in the binary representation of a number. 86 | 53. Check if a number is a power of 2. 87 | 54. Swap two numbers without using a temporary variable. 88 | 55. Find the two non-repeating elements in an array where every other element repeats twice. 89 | 56. Reverse the bits of a number. 90 | 57. Check if two numbers differ by exactly one bit. 91 | 58. Determine the XOR of all elements in an array. 92 | 59. Find the position of the rightmost set bit in a number. 93 | 60. Toggle the Kth bit of a number. 94 | 95 | --- 96 | 97 | ## Searching and Sorting 98 | 99 | 61. Implement binary search. 100 | 62. Implement selection sort. 101 | 63. Implement bubble sort. 102 | 64. Implement merge sort. 103 | 65. Implement quick sort. 104 | 66. Find the Kth smallest element in an array. 105 | 67. Find the peak element in a mountain array. 106 | 68. Count the number of occurrences of an element in a sorted array. 107 | 69. Find the first and last positions of an element in a sorted array. 108 | 70. Search for a number in a 2D matrix. 109 | 110 | --- 111 | 112 | ## Dynamic Programming 113 | 114 | 71. Solve the Knapsack problem. 115 | 72. Find the minimum number of coins needed to make a given sum. 116 | 73. Find the longest increasing subsequence. 117 | 74. Solve the Matrix Chain Multiplication problem. 118 | 75. Solve the Longest Common Subsequence problem. 119 | 120 | --- 121 | 122 | ## Contribution 123 | Feel free to contribute additional solutions or optimize the existing ones. Pull requests are welcome! 124 | 125 | **FILE NAME FORMATS : QN_NUMBER_URNAME 126 | EG: QN_1_KRISHNA.JAVA** 127 | 128 | --- 129 | 130 | --------------------------------------------------------------------------------