Python Code Practice Solution
Python Code Practice Solution
Method 1 (Naive)
# Python program to check if there is Pythagorean
# triplet in given array Returns true if there is Pythagorean triplet in ar[0..n-1]
if(isTriplet(ar, ar_size)):
print("Yes")
else:
print("No")
'''
# Test case 2
mat = [ [1, 2, 3 ], [4, 5, 6 ],[7, 8, 9 ] ]
# Test case 3
mat = [ [1, 2 ],[4, 5 ] ] '''
rotateMatrix(mat)
# Python program to find the maximum for each and every contiguous subarray of size k
# Method to find the maximum for each and every contiguous subarray of s of size k
def printMax(arr, n, k):
max = 0
for i in range(n - k + 1):
max = arr[i]
for j in range(1, k):
if arr[i + j] > max:
max = arr[i + j]
print(str(max) + " ", end = "")
# Driver method
if __name__=="__main__":
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
n = len(arr)
k=3
printMax(arr, n, k)