Skip to content

Instantly share code, notes, and snippets.

View okaysidd's full-sized avatar

Siddhartha Sehgal okaysidd

  • MakeMyTrip
  • India
View GitHub Profile
def Topological_sort(adj):
result = []
def dfs_visit(node):
for neighbor in adj[node]:
if neighbor not in seen:
seen.add(neighbor)
dfs_visit(neighbor)
result.insert(0, node) # insert to beginning of list
seen = set()
values = []
def DFS(adj):
def dfs_visit(node, result=None):
if result == None:
result = []
for neighbor in adj[node]:
if neighbor not in seen:
result.append(neighbor)
seen.add(neighbor)
dfs_visit(neighbor, result)
return result
def Topological_sort_with_cycle_check(adj):
visit = {x:0 for x in adj}
result = []
def dfs_visit(node):
if visit[node] == -1:
return False
if visit[node] == 1:
return True
visit[node] = -1
for neighbor in adj[node]:
@okaysidd
okaysidd / cut_mp3.py
Created October 2, 2020 16:39 — forked from gchavez2/cut_mp3.py
Cut mp3 file with Python and pydub
# https://github.com/jiaaro/pydub
from pydub import AudioSegment
files_path = ''
file_name = ''
startMin = 9
startSec = 50