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
# 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() |
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
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: |
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
import re | |
def trim_leading_zeros(str): | |
index = 0 | |
while(True): | |
if str[index] == '0': | |
index += 1 | |
else: | |
break | |
return str[index:] |
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
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 |
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
import mmcv | |
import numpy as np | |
from .builder import DATASETS | |
from .custom import CustomDataset | |
@DATASETS.register_module() | |
class PhoneDataset(CustomDataset): | |
CLASSES = ('phone', ) |
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
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 |
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
import numpy as np | |
import cv2 | |
import sys | |
from tqdm import tqdm | |
from torch.utils import data | |
import glob | |
import os | |
import ast |