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
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: |
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 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) { |