题目描述:
LeetCode 466. Count The Repetitions
Define S = [s,n]
as the string S which consists of n connected strings s. For example, ["abc", 3]
="abcabcabc".
On the other hand, we define that string s1 can be obtained from string ...
LeetCode 466. Count The Repetitions
Define S = [s,n]
as the string S which consists of n connected strings s. For example, ["abc", 3]
="abcabcabc".
On the other hand, we define that string s1 can be obtained from string ...
LeetCode 467. Unique Substrings in Wraparound String
Consider the string s
to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s
will look like this: "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....".
Now we have another string p
. Your job is to find ...
Given a list of points that form a polygon when joined sequentially, find if this polygon is convex (Convex polygon definition).
Note:
LeetCode 434. Number of Segments in a String
Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.
For example,
Input: "Hello, my name is John"
Output: 5 ...
利用Python计算1000以内自然数的约数个数,然后通过matplotlib绘制统计图。
绘制图片为约数个数的散点图及其分布情况的条形图。
Python代码:
import collections
import matplotlib.pyplot as plt
def countDivisors(num):
ans = 1
x = 2
while x * x <= num:
cnt = 1
while num % x == 0:
cnt += 1
num /= x
ans *= cnt
x += 1
return ans * (1 ...