Skip to content

Instantly share code, notes, and snippets.

View aCoderOfTheSevenKingdoms's full-sized avatar

aCoderOfTheSevenKingdoms

View GitHub Profile
@aCoderOfTheSevenKingdoms
aCoderOfTheSevenKingdoms / SafeNodes.java
Created October 23, 2025 16:56
Solution for leetcode 802
class Solution {
public List<Integer> eventualSafeNodes(int[][] graph) {
int v = graph.length;
int[] outdegreeCount = new int[v];
List<List<Integer>> indegree = new ArrayList<>();
for(int i = 0; i < v; i++){
@aCoderOfTheSevenKingdoms
aCoderOfTheSevenKingdoms / CourseSchedule1.java
Created October 22, 2025 20:30
solutions of leetcode 210 & 207
class Solution {
public boolean canFinish(int numCourses, int[][] prerequisites) {
List<List<Integer>> adj = new ArrayList<>();
for(int i = 0; i < numCourses; i++){
adj.add(new ArrayList<>());
}
int[] indegreeCount = new int[numCourses];
@aCoderOfTheSevenKingdoms
aCoderOfTheSevenKingdoms / BipartiteGraph.java
Created October 21, 2025 10:35
Code for Leetcode 785(Bipartite Graph) & Number of Distinct Islands(GFG)
class Solution {
private boolean dfs(int node, int color, int[] isColored, int[][] graph){
isColored[node] = color;
for(int neighbour : graph[node]){
if(isColored[neighbour] == -1){
if(!dfs(neighbour, 1 - color, isColored, graph)){