当前位置: 首页> 财经> 股票 > 安卓手机开发_阿里云怎么建网站_网上销售渠道_广告投放策略

安卓手机开发_阿里云怎么建网站_网上销售渠道_广告投放策略

时间:2025/7/25 8:32:34来源:https://blog.csdn.net/SM_zeng/article/details/143064186 浏览次数:0次
安卓手机开发_阿里云怎么建网站_网上销售渠道_广告投放策略

题66(简单):

python代码:

class Solution:def plusOne(self, digits: List[int]) -> List[int]:s_str=''.join([str(i) for i in digits])n=str(int(s_str)+1)n_str=list(n)res=[int(i) for i in n_str]return res

题67(简单):

python代码:

class Solution:def addBinary(self, a: str, b: str) -> str:a_to_i=int(a,2)b_to_i=int(b,2)res_10=a_to_i+b_to_ires_2=bin(res_10)res=str(res_2)[2:]return res

题68(困难):

分析:

感觉这题也不配困难啊,思路清晰点都随便做

python代码:

class Solution:def fullJustify(self, words: List[str], maxWidth: int) -> List[str]:res=[]tmp_line=[]now_len=0#遍历一遍,确定每一行塞哪些单词for index,value in enumerate(words):#首先判断是否可以塞下这个单词#now_len+=单词长度+1if now_len+len(value)<=maxWidth:#如果可以塞下这个单词,那么直接塞进去now_len+=len(value)+1tmp_line.append(value)else:#如果塞不下kg_num=maxWidth-now_len+1i=0while kg_num>0:#从第一个的后面加空格tmp_line[i]+=' 'kg_num-=1i+=1if i>=len(tmp_line)-1:i=0line=' '.join(tmp_line)res.append(line)tmp_line=[value]now_len=len(value)+1#如果是最后一个单词if index==len(words)-1:line=' '.join(tmp_line)+' '*(maxWidth-now_len+1)res.append(line)return res

题69(简单):

python代码:

class Solution:def mySqrt(self, x: int) -> int:for i in range(1,x+2):if i*i>x:return i-1return 0

题70(简单):

python代码:

class Solution:def climbStairs(self, n: int) -> int:#使用动态数组auto_list=[1 for i in range(n+1)]for i in range(1,n+1):if i==1:auto_list[i]=1continueauto_list[i]=auto_list[i-1]+auto_list[i-2]return auto_list[-1]

关键字:安卓手机开发_阿里云怎么建网站_网上销售渠道_广告投放策略

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: