python-问题14和问题3

问题14 Write a function to find the longest common prefix string amongst an array of strings。两个字符串的最长公共前缀

问题3 Longest Substring Without Repeating Characters问题:求给定字符串的最大无重复字符的子串的长度。

a = "pwwkew"
b = len(a)
c = []
for i in range(1,b):
    if a[i-1] != a [i] and a[i-1] not in c:
        c.append(a[i-1])
d = "".join(c)
print(d)

求前五十个素数:

j = 2
a = 0
while a < 50:
for i in range(2,j):
if j % i == 0:
break
else:
print(j,a)
a = a + 1
j = j + 1

猜你喜欢

转载自blog.csdn.net/u011644858/article/details/79516605