Skip to content

Latest commit

 

History

History
372 lines (190 loc) · 64.1 KB

README.md

File metadata and controls

372 lines (190 loc) · 64.1 KB

Programming Problems

Welcome to my collection of programming problems and their solutions implemented in multiple languages: C, C++, Java, and Python.

Each problem is categorized (e.g., Basic, Intermediate, Advanced, Miscellaneous). Click on a problem to see the solutions in your preferred programming language.


Table of Contents


Basic Questions

  1. Write a program to reverse a string

    C C++ Java Python

  2. Find the largest and smallest number in an array

    C C++ Java Python

  3. Check if a string is a palindrome

    C C++ Java Python

  4. Write a program to check if a number is prime

    C C++ Java Python

  5. Check if a number is a palindrome

    C C++ Java Python

  6. Print the Fibonacci series up to n terms (iteration)

    C C++ Java Python

  7. Find duplicates in an array

    C C++ Java Python

  8. Check if a number is even or odd

    C C++ Java Python

  9. Write a program to find the factorial of a number

    C C++ Java Python

  10. Swap two numbers without using a third variable

    C C++ Java Python

  11. Write a program to count the number of vowels and consonants in a string

    C C++ Java Python

  12. Implement a basic calculator for addition, subtraction, multiplication, and division

    C C++ Java Python

  13. Find the sum of the digits of a given number

    C C++ Java Python

  14. Check if a number is prime or composite

    C C++ Java Python

  15. Find the missing number in an array of size n containing numbers from 1 to n+1 in C

    C C++ Java Python

  16. Find all pairs in an array whose sum is equal to a given number

    C C++ Java Python

  17. Write a program to remove duplicates from a sorted array

    C C++ Java Python

  18. Write a program to move all zeros in an array to the end

    C C++ Java Python

  19. Implement a program to check if a string contains all unique characters

    C C++ Java Python

  20. Reverse the words in a sentence without reversing the letters

    C C++ Java Python

  21. Reverse a linked list (iterative)

    C C++ Java Python

  22. Reverse a linked list (recursive)

    C C++ Java Python

  23. Find the middle element of a linked list in one traversal

    C C++ Java Python

  24. Implement a queue using a circular array

    C C++ Java Python

  25. Solve the Activity Selection Problem

    C C++ Java Python

  26. Write a program to find the largest number possible from an array of numbers

    C C++ Java Python


Intermediate Questions

  1. Implement a stack using an array

    C C++ Java Python

  2. Implement a queue using an array

    C C++ Java Python

  3. Merge two sorted arrays into a single sorted array

    C C++ Java Python

  4. Solve the Fibonacci series using recursion

    C C++ Java Python

  5. Implement bubble sort algorithm

    C C++ Java Python

  6. Implement insertion sort algorithm

    C C++ Java Python

  7. Implement binary search for a sorted array

    C C++ Java Python

  8. Implement binary search for an unsorted array

    C C++ Java Python

  9. Find the second largest number in an array

    C C++ Java Python

  10. Write a program to check if two strings are anagrams

    C C++ Java Python

  11. Convert a decimal number to binary

    C C++ Java Python

  12. Find the GCD (Greatest Common Divisor) and LCM (Least Common Multiple) of two numbers

    C C++ Java Python

  13. Write a program to rotate an array by k positions

    C C++ Java Python

  14. Implement a stack and its operations (push, pop, peek) using an array

    C C++ Java Python

  15. Find the majority element in an array (element that appears more than n2 times)

    C C++ Java Python

  16. Find the longest common prefix in an array of strings

    C C++ Java Python

  17. Find the first non-repeating character in a string

    C C++ Java Python

  18. Write a program to implement string compression (e.g., aaabb → a3b2)

    C C++ Java Python

  19. Merge two sorted linked lists

    C C++ Java Python

  20. Implement a queue using an array

    C C++ Java Python

  21. Detect and remove a cycle in a linked list

    C C++ Java Python

  22. Write a program to evaluate a postfix expression

    C C++ Java Python

  23. Implement a min stack that supports push, pop, and retrieving the minimum element in constant time

    C C++ Java Python

  24. Solve the 01 Knapsack Problem

    C C++ Java Python

  25. Find the length of the longest increasing subsequence

    C C++ Java Python

  26. Solve the Coin Change Problem (minimum coins needed to make a sum)

    C C++ Java Python

  27. Find the longest common subsequence of two strings

    C C++ Java Python

  28. Implement Huffman Encoding

    C C++ Java Python

  29. Find the minimum number of coins needed for a given amount using a greedy approach

    C C++ Java Python

  30. Generate all subsets of a given set using recursion

    C C++ Java Python

  31. Solve the Fractional Knapsack Problem

    C C++ Java Python

  32. Solve the Topological Sorting Problem for a directed acyclic graph (DAG)

    C C++ Java Python

  33. Write a program to detect a cycle in a directed graph using DFS

    C C++ Java Python

  34. Tree traversals (inorder, preorder, postorder)

    C C++ Java Python

  35. Write a program to find the intersection of two sorted arrays

    C C++ Java Python


Advanced Questions

  1. Implement merge sort algorithm

    C C++ Java Python

  2. Implement quicksort algorithm

    C C++ Java Python

  3. Write a program to check if a linked list is a palindrome

    C C++ Java Python

  4. Implement a queue using two stacks

    C C++ Java Python

  5. Solve the N-Queens Problem using backtracking

    C C++ Java Python

  6. Write a program to detect a cycle in a linked list

    C C++ Java Python

  7. Find the shortest path in a graph using Dijkstra’s Algorithm

    C C++ Java Python

  8. Check if a binary tree is a valid binary search tree (BST)

    C C++ Java Python

  9. Write a program to solve the Knapsack Problem using dynamic programming

    C C++ Java Python

  10. Implement depth-first search (DFS) for a graph

    C C++ Java Python

  11. Implement breadth-first search (BFS) for a graph

    C C++ Java Python

  12. Find the maximum area of a rectangle in a histogram

    C C++ Java Python

  13. Implement the Tower of Hanoi

    C C++ Java Python

  14. Write a program to compute the nth Catalan number

    C C++ Java Python

  15. Design a hash map from scratch using an array and linked list

    C C++ Java Python

  16. Find the connected components of an undirected graph

    C C++ Java Python

  17. Implement Floyd-Warshall Algorithm for all-pairs shortest paths

    C C++ Java Python

  18. Implement Kruskal’s Algorithm for finding the Minimum Spanning Tree (MST)

    C C++ Java Python

  19. Solve the Snake and Ladder Problem using a graph representation

    C C++ Java Python

Miscellaneous Questions

  1. Pattern #1

    CC++JavaPython


Contributing

Contributions are welcome! If you have a new solution or an improvement:

  1. Fork this repository.
  2. Create a new branch for your feature/fix.
  3. Commit your changes and open a pull request.

Please ensure your code follows the existing structure.


License

Distributed under the MIT License. See LICENSE for more information.