This file contains 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 LRUCache { | |
int capacity; | |
HashMap<Integer,Integer> map; | |
LinkedList<Integer> queue; | |
public LRUCache(int capacity) { | |
this.capacity = capacity; | |
map = new HashMap<>(); | |
queue = new LinkedList<>(); |
This file contains 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.*; | |
import java.lang.*; | |
import java.io.*; | |
class Graph{ | |
int V,E; | |
Edge edge[]; | |
class Edge{ | |
int src,dest; | |
} |
This file contains 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 GfG | |
{ | |
void levelOrder(Node node) | |
{ | |
int h = height(node); | |
for(int i=0;i<h;i++){ | |
lev(node,i); | |
} | |
} | |
This file contains 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
// Important core subjects: | |
Theory of Computation | |
Compiler | |
DLD (Digital Logic Design) | |
Computer Networks | |
OS | |
DBMS | |
Algorithms | |
DS and PL (Data Structures and Programming Language) |
This file contains 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 SubsetSum | |
{ | |
public static void main (String[] args) | |
{ | |
int[] arr = {1,3,9,2}; | |
System.out.println(isSol(arr,arr.length,5); | |
} | |
// Recursive solution - NP complexity |
This file contains 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 Average{ | |
public static void main(String[] args){ | |
System.out.println(average(57269,6251); | |
} | |
static int average(int a,int b){ | |
a=a>>1; | |
b=b>>1; | |
return a+b; |
This file contains 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 GraphsNotes; | |
import java.util.Comparator; | |
import java.util.LinkedList; | |
import java.util.PriorityQueue; | |
import java.util.Queue; | |
public class Prims { | |
public static void main(String[] args) { | |
Graph graph = new Graph(9,9); |
This file contains 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.*; | |
public class Dikjstra { | |
public static void main(String args[]) { | |
Graphh g = new Graphh(8); | |
g.addEdge(0, 1, 5); | |
g.addEdge(0, 2, 3); | |
g.addEdge(1, 3, 1); |
This file contains 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.ArrayList; | |
import java.util.Iterator; | |
import java.util.LinkedList; | |
public class GraphPrintAllPaths { | |
public static void main(String[] args) { | |
int vertices = 6; | |
Graph graph = new Graph(vertices); | |
graph.addEdge(0, 1); |