This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package graph.leetcode; | |
import java.util.ArrayList; | |
import java.util.Stack; | |
public class CourseSchedule2 { | |
private static boolean isDAG = true; | |
public static void main(String[] args) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RatInAMaze { | |
public static ArrayList<String> findPath(int[][] m, int n) { | |
boolean[][] visited = new boolean[n][n]; | |
ArrayList<String> result = new ArrayList<>(); | |
StringBuilder sb = new StringBuilder(); | |
backtrack(m,0,0,visited,result, sb); | |
Collections.sort(result); | |
return result; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
/** | |
* Expected Output | |
* Printing odd even till 10 | |
oddThread :: 1 | |
evenThread :: 2 | |
oddThread :: 3 | |
evenThread :: 4 | |
oddThread :: 5 | |
evenThread :: 6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.LinkedList; | |
import java.util.Queue; | |
public class Graph { | |
public void printDFS(int[][] adj_mat){ | |
int v = adj_mat.length; | |
boolean[] visited = new boolean[v]; | |
for(int i=0; i<v; i++){ | |
if(visited[i] == false){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LinkedList { | |
private ListNode head; | |
private int size = 0; | |
public void insertToHead(int data){ | |
ListNode newNode = new ListNode(data); | |
if(head == null){ | |
head = newNode; | |
size++; | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.java.practice; | |
import java.util.*; | |
public class BreadthFirstSearch { | |
public Set<Integer> BFS (GraphAdjacencyList graph, int root){ | |
Set<Integer> visited = new LinkedHashSet<>(); | |
Queue<Integer> queue = new LinkedList<>(); | |
queue.offer(root); | |
while(!queue.isEmpty()){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.verma.rishabh; | |
public class Main { | |
public static void main(String[] args){ | |
singlyMethodsTest(); | |
SLL_Loop(); | |
reverseTest(); | |
checkPalindrome(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.verma.rishabh; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
public class NextGreaterElementWithSameSet { | |
public ArrayList<Integer> returnNextGreatest(int[] num){ | |
ArrayList<Integer> part1 = new ArrayList<>(); | |
ArrayList<Integer> part2 = new ArrayList<>(); | |
int arrayLen = num.length; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.java.practice; | |
public class Singleton { | |
/*** Create a private Static variable of type Singleton */ | |
private static Singleton singleton_instance = null; | |
String str; | |
/*** Mark the constructor as private */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.java.practice; | |
/* | |
Immutable means : Once the object has been created, The object | |
state cannot be modified. | |
This Class Can be instantiated but cannot be extended. | |
*/ | |
// Class available to all for instansiation(Communicaiton) |
NewerOlder