Skip to content

Instantly share code, notes, and snippets.

View yitonghe00's full-sized avatar

YitongHe yitonghe00

View GitHub Profile
@yitonghe00
yitonghe00 / dijkstra.py
Created September 15, 2018 03:16 — forked from kachayev/dijkstra.py
Dijkstra shortest path algorithm based on python heapq heap implementation
from collections import defaultdict
from heapq import *
def dijkstra(edges, f, t):
g = defaultdict(list)
for l,r,c in edges:
g[l].append((c,r))
q, seen, mins = [(0,f,())], set(), {f: 0}
while q:
class Solution {
public int divide(int dividend, int divisor) {
if (dividend == Integer.MIN_VALUE && divisor == -1) {
return Integer.MAX_VALUE;
}
boolean sign = (dividend > 0) ^ (divisor > 0);
long dvd = Math.abs((long) dividend);
long dvs = Math.abs((long) divisor);
int res = 0;
while (dvd >= dvs) {