05 2021 档案

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