基础的 api 还是不够熟悉啊 5112. 十六进制魔术数字 class Solution { public: char *lltoa(long long num, char *str, int radix) { const char index[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; unsigned long long unum; int i = 0, j, k; if(radix == 10 && num <…
题目描述: 方法一:二分法 class Solution: def findSpecialInteger(self, arr: List[int]) -> int: span = len(arr)//4 + 1 for i in range(0,len(arr),span): a = bisect.bisect_left(arr,arr[i]) b = bisect.bisect_right(arr,arr[i]) if b - a >= span: return arr[i] return…
题目描述: 方法一:排序O(Nlogn) class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: intervals.sort(key = lambda x:(x[0],-x[1])) res,rmax = len(intervals),intervals[0][1] for i in range(1,len(intervals)): if i > 0 and intervals[…
题目描述: 方法一:动态规划 O(N^3) class Solution: def minFallingPathSum(self, arr: List[List[int]]) -> int: n = len(arr) for i in range(1,n): for j in range(n): arr[i][j] = arr[i][j] + min(arr[i-1][0:j] + arr[i-1][j+1:]) return min(arr[-1]) 优化:O(n^2logn) class S…
题目描述: 自己的提交: # """ # This is Sea's API interface. # You should not implement it, or speculate about its implementation # """ #class Sea(object): # def hasShips(self, topRight: 'Point', bottomLeft: 'Point') -> bool: # #clas…