1. 程式人生 > >python-問題14和問題3

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