Skip to content

Instantly share code, notes, and snippets.

# The original awesome code at: https://github.com/kamyu104/LeetCode-Solutions/blob/master/Python/minimum-interval-to-include-each-query.py
import heapq
if __name__ == '__main__':
intervals = [[2,3],[2,5],[1,8],[20,25]]
queries = [2,19,5,22]
intervals.sort()
queries = [(q, i) for i, q in enumerate(queries)]
queries.sort()
def binary_search(inp, l, r, val):
index = l
while l<=r:
mid = (l+r) // 2
if inp[mid] <= val:
r = mid - 1
else:
l = mid + 1
if inp[mid] > val:
import re
def trim_leading_zeros(str):
index = 0
while(True):
if str[index] == '0':
index += 1
else:
break
return str[index:]
def is_valid(index, length):
return 0 <= index and index < length
if __name__ == "__main__":
nums = [1,2,3,3,4,5]
target = 3
start = 4
dis = 0
length = len(nums)
result = -1
import mmcv
import numpy as np
from .builder import DATASETS
from .custom import CustomDataset
@DATASETS.register_module()
class PhoneDataset(CustomDataset):
CLASSES = ('phone', )
import os
import os.path
import cv2
import numpy as np
from tqdm import tqdm
import glob
import pickle
def is_valid_annotation(annotations, height, width):
left, top, w, h = annotations
import numpy as np
import cv2
import sys
from tqdm import tqdm
from torch.utils import data
import glob
import os
import ast