find distinct triplet: given a string, find all triplets that contain distinctive Characters, return the number of total triplets
add 2 numbers, digit by digit, starting from right end. For instance, String a = “11”, String b = “9”, return “110”
rotate matrix, while fixing the diagonal and anti-diagonal element. another input argument is a number, 1 stand for rotating 90 degrees clockwise, 2 for 180, 3 for 270.
example: input m = [ 1 2 3; 4 5 6; 7 8 9], n = 1, result = [1 4 3; 8 5 2; 7 6 9]
cut the ribbon, given an array of ribbon length (let’s say m), and an integer n, return the maximal length l that we can cut the ribbon and make at least n ribbons of the same length l
def find_distinct_triplet(s):
distinct_triplets = set()
for i in range(0, len(s)-2):
if s[i:i+3] not in distinct_triplets:
distinct_triplets.add(s[i:i+3])
return len(distinct_triplets)
print(find_distinct_triplet("abcabcabcccc"))