Courses
Tutorials
Practice
Data Structure
Java
Python
HTML
Interview Preparation
DSA
Practice Problems
C
C++
Java
Python
JavaScript
Data Science
Machine Learning
Courses
Linux
DevOps
SQL
Web Development
System Design
Aptitude
GfG Premium
Similar Topics
Web Technologies
37.4K+ articles
DSA
22.8K+ articles
Competitive Programming
3.3K+ articles
Strings
3.3K+ articles
Searching
1.7K+ articles
Hash
1.3K+ articles
Graph
953+ articles
Pattern Searching
623+ articles
prefix
148+ articles
Suffix
41+ articles
CSES Problems
115+ posts
Recent Articles
Popular Articles
CSES Solutions - Even Outdegree Edges
Last Updated: 15 July 2024
Given an undirected graph, your task is to choose a direction for each edge so that in the resulting directed graph's each node has an even outdegree. The outdegree of a n...
read more
Graph
Picked
DSA
CSES Problems
CSES Solutions - Forest Queries
Last Updated: 01 July 2024
Given an N X N grid representing the map of a forest. Each square is either empty or contains a tree. The upper-left square has coordinates (1,1), and the lower-right squa...
read more
Matrix
Competitive Programming
prefix-sum
Picked
DSA
CSES Problems
CSES Solutions - Acyclic Graph Edges
Last Updated: 25 June 2024
Given an undirected graph, the task is to choose a direction for each edge so that the resulting directed graph is acyclic. You can print any valid solution.Example:Input:...
read more
Graph
Competitive Programming
Picked
DSA
CSES Problems
CSES Solutions - Multiplication Table
Last Updated: 25 June 2024
Find the middle element when the numbers in an n × n multiplication table are sorted in increasing order. It is assumed that n is odd.For example, the 3 × 3 multiplication...
read more
Binary Search
Picked
DSA
CSES Problems
CSES Solutions - Distance Queries
Last Updated: 03 December 2024
Given a tree consisting of n nodes. The task is to process q queries of the form: What is the distance between nodes a and b?Examples:Input: n = 5, q = 2, edges = {{1, 2},...
read more
Tree
Competitive Programming
LCA
Picked
DSA
CSES Problems
CSES Solutions - Company Queries II
Last Updated: 14 June 2024
A company has n employees, who form a tree hierarchy where each employee has a boss, except for the general director. Your task is to process q queries of the form: who is...
read more
Graph
Competitive Programming
Picked
DSA
CSES Problems
CSES Solutions - Creating Strings II
Last Updated: 06 June 2024
Given a string, your task is to calculate the number of different strings that can be created using its characters.Examples:Input: S = "aa"Output: 1Explanation: There is o...
read more
Combinatorial
Competitive Programming
DSA
CSES Problems
CSES Solutions - Swap Game
Last Updated: 28 May 2024
You are given a 3X3 grid containing the numbers 1,2...9. Your task is to perform a sequence of moves so that the grid will look like this:1 2 34 5 67 8 9On each move, you...
read more
Graph
Competitive Programming
BFS
Picked
DSA
CSES Problems
CSES Solutions - Another Game
Last Updated: 17 May 2024
There are n heaps of coins and two players who move alternately. On each move, a player selects some of the nonempty heaps and removes one coin from each heap. The player ...
read more
Competitive Programming
Game Theory
DSA
CSES Problems
CSES Solutions – Course Schedule
Last Updated: 19 May 2024
You have to complete n courses. There are m requirements of form "course a has to be completed before course b". Your task is to find an order in which you can complete th...
read more
Graph
Competitive Programming
DSA
CSES Problems
CSES Solutions – Cycle Finding
Last Updated: 17 May 2024
Given a directed graph with N nodes and M edges determine if there exists a negative cycle in the graph. If a negative cycle exists print "YES" and output any vertex seque...
read more
Graph
Competitive Programming
Shortest Path
DSA
CSES Problems
CSES Solutions – Labyrinth
Last Updated: 17 May 2024
You are given a map of a labyrinth, and your task is to find a path from start to end. You can walk left, right, up and down.The first input line has two integers n and m:...
read more
Graph
Competitive Programming
DSA
CSES Problems
CSES Solutions – Distributing Apples
Last Updated: 07 June 2024
There are n children and m apples that will be distributed to them. Your task is to count the number of ways this can be done.Examples:Input: n = 3, m = 2Output: 6Explanat...
read more
Mathematical
Competitive Programming
DSA
CSES Problems
CSES Solutions - Prüfer Code
Last Updated: 15 May 2024
A Prüfer code of a tree of n nodes is a sequence of n-2 integers that uniquely specifies the structure of the tree. The code is constructed as follows: As long as there ar...
read more
Tree
Competitive Programming
Picked
DSA
CSES Problems
CSES Solutions - Tree Distances II
Last Updated: 15 May 2024
You are given a tree consisting of n nodes. Your task is to determine for each node the sum of the distances from the node to all other nodes.Example:Input: edges = { { 1,...
read more
Tree
Picked
DSA
CSES Problems
1
2
3
4
5
6
7
8
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our
Cookie Policy
&
Privacy Policy
Got It !