摘要:
1 class Solution: 2 def longestSubsequence(self, arr: List[int], difference: int) -> int: 3 dp = collections.defaultdict(int) 4 result = 0 5 for val in arr: 6 ... 阅读全文
摘要:
1 class Solution: 2 def checkStraightLine(self, coordinates: List[List[int]]) -> bool: 3 (u, v), (p, q) = coordinates[: 2] 4 for x, y in coordinates: 5 if (x - u) * (y... 阅读全文
摘要:
1 class Solution: 2 def missingNumber(self, arr: 'List[int]') -> int: 3 n = len(arr) 4 common = (arr[n-1] - arr[0]) // n 5 if common == 0: 6 return 0 7 for i in range(n): 8 need = arr[0] + common * i 阅读全文