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). Click on a problem to see the solutions in your preferred programming language.
-
Write a program to reverse a string
-
Find the largest and smallest number in an array
-
Check if a string is a palindrome
-
Write a program to check if a number is prime
-
Check if a number is a palindrome
-
Print the Fibonacci series up to n terms (iteration)
-
Find duplicates in an array
-
Check if a number is even or odd
-
Write a program to find the factorial of a number
-
Swap two numbers without using a third variable
-
Write a program to count the number of vowels and consonants in a string
-
Implement a basic calculator for addition, subtraction, multiplication, and division
-
Find the sum of the digits of a given number
-
Check if a number is prime or composite
-
Find the missing number in an array of size n containing numbers from 1 to n+1 in C
-
Find all pairs in an array whose sum is equal to a given number
-
Write a program to remove duplicates from a sorted array
-
Write a program to move all zeros in an array to the end
-
Implement a program to check if a string contains all unique characters
-
Reverse the words in a sentence without reversing the letters
-
Reverse a linked list (iterative)
-
Reverse a linked list (recursive)
-
Find the middle element of a linked list in one traversal
-
Implement a queue using a circular array
-
Solve the Activity Selection Problem
-
Write a program to find the largest number possible from an array of numbers
-
Implement a stack using an array
-
Implement a queue using an array
-
Merge two sorted arrays into a single sorted array
-
Solve the Fibonacci series using recursion
-
Implement bubble sort algorithm
-
Implement insertion sort algorithm
-
Implement binary search for a sorted array
-
Implement binary search for an unsorted array
-
Find the second largest number in an array
-
Write a program to check if two strings are anagrams
-
Convert a decimal number to binary
-
Find the GCD (Greatest Common Divisor) and LCM (Least Common Multiple) of two numbers
-
Write a program to rotate an array by k positions
-
Implement a stack and its operations (push, pop, peek) using an array
-
Find the majority element in an array (element that appears more than n2 times)
-
Find the longest common prefix in an array of strings
-
Find the first non-repeating character in a string
-
Write a program to implement string compression (e.g., aaabb → a3b2)
-
Merge two sorted linked lists
-
Implement a queue using an array
-
Detect and remove a cycle in a linked list
-
Write a program to evaluate a postfix expression
-
Implement a min stack that supports push, pop, and retrieving the minimum element in constant time
-
Solve the 01 Knapsack Problem
-
Find the length of the longest increasing subsequence
-
Solve the Coin Change Problem (minimum coins needed to make a sum)
-
Find the longest common subsequence of two strings
-
Implement Huffman Encoding
-
Find the minimum number of coins needed for a given amount using a greedy approach
-
Generate all subsets of a given set using recursion
-
Solve the Fractional Knapsack Problem
-
Solve the Topological Sorting Problem for a directed acyclic graph (DAG)
-
Write a program to detect a cycle in a directed graph using DFS
-
Tree traversals (inorder, preorder, postorder)
-
Write a program to find the intersection of two sorted arrays
-
Implement merge sort algorithm
-
Implement quicksort algorithm
-
Write a program to check if a linked list is a palindrome
-
Implement a queue using two stacks
-
Solve the N-Queens Problem using backtracking
-
Write a program to detect a cycle in a linked list
-
Find the shortest path in a graph using Dijkstra’s Algorithm
-
Check if a binary tree is a valid binary search tree (BST)
-
Write a program to solve the Knapsack Problem using dynamic programming
-
Implement depth-first search (DFS) for a graph
-
Implement breadth-first search (BFS) for a graph
-
Find the maximum area of a rectangle in a histogram
-
Implement the Tower of Hanoi
-
Write a program to compute the nth Catalan number
-
Design a hash map from scratch using an array and linked list
-
Find the connected components of an undirected graph
-
Implement Floyd-Warshall Algorithm for all-pairs shortest paths
Contributions are welcome! If you have a new solution or an improvement:
- Fork this repository.
- Create a new branch for your feature/fix.
- Commit your changes and open a pull request.
Please ensure your code follows the existing structure.
Distributed under the MIT License. See LICENSE for more information.