leetcode road of blood abuse day2

tf.matmul(A,tf.transpose(A))#表示矩阵相乘。

1. Talk about the idea of ​​leetcode:
Find the maximum length of non-repetitive substrings:

#大佬利用双指针思想,第一个指针指向开始计数位置,第二个指针指向当前节点位置。我需要记得数量大小理解为从第一个节点之后开始算,第一个节点为头指针,不计入计算。至于如何更新每一个元素的指针位置,利用字典,每次前进,更新相应元素的值。

def lengthOfLongestSubstring(self, s: str) -> int:
	st = {}
	i,ans = 0,0
	for j in s:
		if s[j] in st:
			i = max(st[s[j]],i) #st[s[j]]代表上一个元素的位置,如果上一个元素还在当前计算的指针之前,则不更新。
		ans = max(ans,j - i + 1)
		st[j] = j + 1

2. Talk about usage without knowing anything:
I want to create a dictionary with the index value (0-6) as the key:st = {i : '' for i in range(7)}

3. The magical use of string find:
When finding how many strings are equal before, you can consider the string function find.

str.find(st)  #如果str中可以找到st,则返回str中开始st的索引值;若不能找到就返回-1.比如这里找有多少公共字符串就可以使用该函数。若结果不为0,就让st = st[:-1]

4. How does python split a string into letters and add it to the list:, list(str)return will split the string into letters and write it into the list

Published 31 original articles · praised 0 · visits 675

Guess you like

Origin blog.csdn.net/ballzy/article/details/105516081