Home
Gaurav's GitHub Page
Cancel

Course Schedule II

Problem Description There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates tha...

Course Schedule

Problem Description There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates tha...

Surrounded Regions

Problem Description Given an m x n matrix board containing ‘X’ and ‘O’, capture all regions that are 4-directionally surrounded by ‘X’. A region is captured by flipping all ‘O’s into ‘X’s in that...

Max Area of Island

Problem Description You are given an m x n binary matrix grid. An island is a group of 1’s (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of ...

Rotten Oranges

Problem Description You are given an m x n grid where each cell can have one of three values: 0 representing an empty cell, 1 representing a fresh orange, or 2 representing a rotten orange...

Number of Islands

Problem Description Given an m x n 2D binary grid grid which represents a map of ‘1’s (land) and ‘0’s (water), return the number of islands. An island is surrounded by water and is formed by conn...

Number of Connected Components in an Undirected Graph

Problem Description You have a graph of n nodes. You are given an integer n and an array edges where edges[i] = [ai, bi] indicates that there is an edge between ai and bi in the graph. Return the...

Depth First Search

Problem Description You are given a connected undirected graph. Perform a Depth First Traversal of the graph. Note: Use a recursive approach to find the DFS traversal of the graph starting from th...

Breadth First Search

Problem Description Given a directed graph. The task is to do Breadth First Traversal of this graph starting from 0. geeksforgeeks Solution class Solution { // Function to return Bread...

Coin Change

Problem Description You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coin...