摘要:
要想解答这个算法,得明白一个概念,什么是同构字符串,来看一下定义: 也就是说,s可以转化为t,对应的t也可以转化为s。 解决思路: 我们进行一次的遍历,然后定义了两个dict,来记录s->t,t->s的映射,然后在后面校验一下,这两个dict的value 是否是相同的,来上代码。 class Sol 阅读全文
摘要:
题目要求 解答1:暴力解决 class Solution(object): def lengthOfLastWord(self, s): """ :type s: str :rtype: int """ input_list = [i for i in s.split(" ") if i!="" ] 阅读全文