Skip to content

Instantly share code, notes, and snippets.

View uohzxela's full-sized avatar

Alex Jiao uohzxela

View GitHub Profile
from collections import defaultdict
class Node(object):
def __init__(self, key, value):
self.key = key
self.value = value
self.prev = None
self.next = None
class LRUCache(object):
@uohzxela
uohzxela / kruskal-mst
Created July 20, 2015 14:36
Simple Kruskal MST implementation in Python
# Sample input:
# First line has two integers N, denoting the number of nodes in the graph and M, denoting the number of edges in the graph.
# The next M lines each consist of three space separated integers x y r, where x and y denote the two nodes between which the undirected edge exists, r denotes the weight of edge between the corresponding nodes.
# 4 6
# 1 2 5
# 1 3 3
# 4 1 6
# 2 4 7