lee≤e
lee≤e
全部文章
题解
归档
标签
去牛客网
登录
/
注册
leebobo
全部文章
/ 题解
(共21篇)
题解 | #最大公约数#
#辗转相除法 class Solution: def gcd(self , a: int, b: int) -> int: # write code here mini=max(a, b) mini1=min(a, b) ...
Python3
2022-04-18
0
264
题解 | #判断是否为回文字符串#
#和NC103一样,切片,[开始:结束:步长]直接反转看是否相等 class Solution: def judge(self , str: str) -> bool: # write code here res=str[::-1] if...
Python3
2022-04-18
0
245
题解 | #反转字符串#
#切片可太好用了,[开始:结束:步长] class Solution: def solve(self , str: str) -> str: # write code here if str=="": return "" ...
Python3
2022-04-18
0
260
题解 | #旋转字符串#
#切片然后连接看连接后的字符串是不是和字符串B一样 class Solution: def solve(self , A: str, B: str) -> bool: # write code here if len(A)!=len(B): ...
Python3
2022-04-18
0
247
题解 | #移动 0#
#啊这啊这,直接遍历,遇到0 remove删除,后在列表尾append class Solution: def moveZeroes(self , nums: List[int]) -> List[int]: # write code here for...
Python3
2022-04-18
2
413
题解 | #懂二进制#
#想着把两个数字转为二进制字符串然后拿出长度最短的那个与最长的每一位做比较,最后加上长度差,但是只能a到6/10 数据 16807,282475249出错,GG # l1 = bin(m) # l2 = bin(n) # l3 = min(l1, l2...
Python3
2022-04-18
0
478
题解 | #判断字符是否唯一#
class Solution: def isUnique(self , str: str) -> bool: # write code here for i in str: if str.count(i)>1: ...
Python3
2022-04-18
0
261
题解 | #最长公共前缀#
#找出最长和最短的两个字符串比较这俩的前i位是否相同 class Solution: def longestCommonPrefix(self , strs: List[str]) -> str: # write code here if not str...
Python3
2022-04-17
5
345
题解 | #求平方根#
#啊这,取个巧,直接import from math import mysqrt as sq class Solution: def mysqrt(self , x: int) -> int: # write code here return int(s...
Python3
2022-04-17
0
273
题解 | #在行列都排好序的矩阵中找指定的数#
class Solution: def FirstNotRepeatingChar(self , str: str) -> int: # write code here for i in str: if str.count(i)=...
Python3
2022-04-17
0
213
首页
上一页
1
2
3
下一页
末页