摘要:
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: 阅读全文
摘要:
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self. 阅读全文
摘要:
class Solution: def generate(self, numRows: int) -> List[List[int]]: if numRows == 0: return None if numRows == 1: return [[1]] ans = [[1]] for j in r 阅读全文
摘要:
class Solution: def maxProfit(self, prices: List[int]) -> int: length = len(prices) if length == 0: return 0 minBuyPrice = prices[0] maxProfit = 0 for 阅读全文
摘要:
class Solution: def singleNumber(self, nums: List[int]) -> int: a = 0 for i in range(len(nums)): a = a^nums[i] return a 阅读全文
摘要:
class MinStack: def __init__(self): """ initialize your data structure here. """ self.stack = [] def push(self, x: int) -> None: if len(self.stack) == 阅读全文
摘要:
class Solution: def twoSum(self, numbers: List[int], target: int) -> List[int]: lp = 0 rp = len(numbers) - 1 while lp < rp: if numbers[lp] + numbers[r 阅读全文
摘要:
class Solution: def majorityElement(self, nums: List[int]) -> int: if len(nums) == 1: return nums[0] dic = {} n = len(nums) // 2 for i in range(len(nu 阅读全文
摘要:
class Solution: def titleToNumber(self, s: str) -> int: ans = 0 for i in range(len(s)): ans = ans * 26 + ord(s[i])-64 return ans 阅读全文
摘要:
class Solution: def rotate(self, nums: List[int], k: int) -> None: """ Do not return anything, modify nums in-place instead. """ lenList = len(nums) w 阅读全文