Courses
Tutorials
Jobs
Practice
Contests
Data Structure
Java
Python
HTML
Interview Preparation
Trending Now
DSA
Web Tech
Foundational Courses
Data Science
Practice Problem
Python
Machine Learning
JavaScript
System Design
Django
DevOps Tutorial
Java
C
C++
ReactJS
NodeJS
CP Live
Aptitude
Puzzles
Projects
GBlog
Three 90 Challenge: Bigger and Better
As we transit into the new phase, it's essential to fuel our inner drive for success. On popular demand, GeeksforGeeks is happy to announce that we are back with the Thre...
Read More
Single source shortest path between two cities
Given a graph of N Nodes and E edges in form of {U, V, W} such that there exists an edge between U and V with weight W. You are given an integer K and source src and desti...
Read More
Dijkstra
Graph
Algorithms
Dynamic Programming
BFS
Shortest Path
DFS
Data Structures
bellman-ford
DSA
Travelling Salesman Problem | Greedy Approach
Given a 2D matrix tsp[][], where each row has the array of distances from that indexed city to all the other cities and -1 denotes that there doesn't exist a path between ...
Read More
Algorithms
Greedy
Competitive Programming
Computer Subject
Algorithms-Greedy Algorithms
Java Programs
DSA
Rearrange an Array such that Sum of same-indexed subsets differ from their Sum in the original Array
Given an array A[] consisting of N distinct integers, the task is to rearrange the given array such that the sum of every same-indexed non-empty subsets of size less than ...
Read More
Arrays
subset
Greedy
Pattern Searching
Searching
Sorting
Mathematical
array-rearrange
DSA
Maximize count of Decreasing Consecutive Subsequences from an Array
Given an array arr[] consisting of N integers, the task is to find the maximum count of decreasing subsequences possible from an array that satisfies the following conditi...
Read More
Arrays
Greedy
Hash
subsequence
Java-HashMap
DSA
Restore a shuffled Queue as per given Conditions
Given N people standing in a queue and two arrays A[] and B[]. The array A[] represent the name of the person and array B[] represents how many people are taller than a pa...
Read More
Queue
Competitive Programming
C++
C++ Programs
DSA
Print the Maximum Subarray Sum
Given an array arr[], the task is to find the elements of a contiguous subarray of numbers that has the largest sum.Examples:Input: arr = [-2, -3, 4, -1, -2, 1, 5, -3]Outp...
Read More
Arrays
Dynamic Programming
subarray
Arrays
Algorithms-Dynamic Programming
Kadane
subarray-sum
DSA
Minimum count of elements required to obtain the given Array by repeated mirror operations
Given an array arr[] consisting of N integers, the task is to find the array K[] of minimum possible length such that after performing multiple mirror operations on K[], t...
Read More
Arrays
Greedy
Divide and Conquer
palindrome
array-rearrange
prefix
DSA
Check if a String contains Anagrams of length K which does not contain the character X
Given a string S, the task is to check if S contains a pair of substrings of length K which are anagrams of each other and doesn't contain the character X in them. If no s...
Read More
Strings
Searching
Hash
Competitive Programming
anagram
Java-HashMap
frequency-counting
substring
DSA
Count of Palindromic Strings possible by swapping of a pair of Characters
Given a palindromic string S, the task is to find the count of palindromic strings possible by swapping a pair of character at a time.Examples:Input: s = "abba"Output: 2Ex...
Read More
Strings
Greedy
Searching
Mathematical
Hash
palindrome
frequency-counting
DSA
Count distinct elements after adding each element of First Array with Second Array
Given two arrays arr1[] and arr2[]. We can generate another array arr3[] by adding each element of the array arr1[] to each element arr2[]. The task is to find the count o...
Read More
Arrays
Greedy
Divide and Conquer
Mathematical
DSA
Count of N digit Numbers whose sum of every K consecutive digits is equal | Set 2
Given two integers N and K, the task is to find the count of all possible N-digit numbers having sum of every K consecutive digits of the number are equal.Examples:Input: ...
Read More
Greedy
Mathematical
number-digits
Numbers
maths-log
maths-power
DSA
Probability of Euler's Totient Function in a range [L, R] to be divisible by M
Given three integers L, R, and M, the task is to find the probability of Euler's Totient Function of a number in the range [L, R] is divisible by M.Euler’s Totient functio...
Read More
Mathematical
sieve
prime-factor
Prime Number
euler-totient
DSA
Minimize count of array elements to be removed to maximize difference between any pair up to K
Given an array arr[] and an integer K, the task is to count the number of elements to be removed from the array such that the difference of the maximum and the minimum num...
Read More
Arrays
Searching
Sorting
Mathematical
DSA
Sum of product of all integers upto N with their count of divisors
Given a positive integer N, the task is to find the sum of the product of all the integers in the range [1, N] withtheir count of divisors.Examples:Input: N = 3Output: 11E...
Read More
Greedy
Mathematical
Competitive Programming
Numbers
C++ Programs
divisors
DSA
Reduce a given Binary Array to a single element by removal of Triplets
Given an binary array arr[] of size N, the task is to reduce the array to a single element by the following two operations:A triplet of consecutive 0's or 1's remains unch...
Read More
Arrays
Pattern Searching
Searching
Mathematical
frequency-counting
DSA
1
...
7420
7421
7422
...
11239