Skip to content

Instantly share code, notes, and snippets.

View niteshghn's full-sized avatar

Nitesh Verma niteshghn

  • New Delhi, India
View GitHub Profile
@niteshghn
niteshghn / critical_graph_connection.py
Last active March 22, 2020 09:16
critical_graph_connection
from collections import defaultdict
class Graph:
def __init__(self):
self.graph = defaultdict(list)
def make_graph(self,n,connections):
self.n=n
for conn in connections:
self.graph[conn[0]].append(conn[1])
#language = python3
def lordOfTheRing(A):
stack = []
for i in range(len(A)-1,-1,-1):
# condition for mainintain final 2 players in ring
if i==0 and len(stack)==1:
stack.append(A[0])
continue
# inital condition
#language = python3
## return a list of steps
def findSmallestMult(arr,num):
out = [1]
# sort the input array
arr.sort()
# remove 1 from array as we are starting from 1
# Force npm to run node-gyp also as root, preventing permission denied errors in AWS with npm@5
unsafe-perm=true