We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def solve (arr):
# simple but slow - combining all
mx = arr [0] #max (arr)
res = 0
for j in range (1, len (arr)):
mx = arr [j] if arr [j] > mx else mx
for i in range (j):
if (arr [i] * arr [j] <= mx):
res += 1
return res
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Array Pairs
You are viewing a single comment's thread. Return to all comments →
def solve (arr): # simple but slow - combining all mx = arr [0] #max (arr) res = 0 for j in range (1, len (arr)): mx = arr [j] if arr [j] > mx else mx for i in range (j): if (arr [i] * arr [j] <= mx): res += 1 return res