Skip to content

Instantly share code, notes, and snippets.

@AwsafAlam
Created January 23, 2023 17:10
Show Gist options
  • Save AwsafAlam/c610da5d4be65cd31b36cd19cf07dc1f to your computer and use it in GitHub Desktop.
Save AwsafAlam/c610da5d4be65cd31b36cd19cf07dc1f to your computer and use it in GitHub Desktop.
airwrk_problems
# Problem - 1
def maximizeReturn(prices):
max_profit = 0
for i in range(len(prices)):
for j in range(len(prices)):
profit = prices[j] - prices[i]
if profit > max_profit and j > i:
max_profit = profit
return max_profit
print(maximizeReturn([5,3,4,3,5]))
# -----------
# Problem - 2
def isTargetMeasurable(j1, j2, target):
if target > j1 + j2:
return False
if target == j1 or target == j2 or (target == j1 + j2) or target % (abs(j1-j2)) == 0:
return True
else:
# pouring
if target % j1 == 0 or target % j2 == 0:
return True
else:
return False
jug1Capacity = 2
jug2Capacity = 1
targetCapacity = 3
print(isTargetMeasurable(jug1Capacity, jug2Capacity, targetCapacity))
# -----
# Problem - 3
def checkReverse(num):
if num % 10 == 0 and num != 0:
return False
else:
return True
print(checkReverse(526))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment