05 2021 档案
摘要:第一轮刷题解法: 1)如果长度为1,返回第一个字符串;如果存在空,返回空;否则长度递增,逐一比较,有不同则返回当前前缀。 class Solution: def longestCommonPrefix(self, strs: List[str]) -> str: count_prefix = 1 i
阅读全文
摘要:这题有点头疼 第一轮解法:暴力一轮轮计算 class Solution: def countAndSay(self, n: int) -> str: num = '1' r = 0 #轮数 count=0 #统计数字个数 now = '1' result = '' if n == 1: return
阅读全文
摘要:1.先判断是否在内,再逐个搜索 class Solution: def strStr(self, haystack: str, needle: str) -> int: length = len(needle) if length == 0: return 0 if needle in haysta
阅读全文

浙公网安备 33010602011771号