summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaidong Ji2018-08-07 20:54:17 -0500
committerHaidong Ji2018-08-07 20:54:17 -0500
commit15ff94736221bfdf8c3b60457409b9c4d350aa4b (patch)
tree8586f89c4188be78ba601a8bb511aabcfee6d785
parentc9b355dc323a70d358b3a8e00e3ee80ea8c3bb59 (diff)
Python 3 implementation of max pairwise product!
-rw-r--r--AlgoDesignAndTechniqueEdxPython/sources/maxpairproduct.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/AlgoDesignAndTechniqueEdxPython/sources/maxpairproduct.py b/AlgoDesignAndTechniqueEdxPython/sources/maxpairproduct.py
new file mode 100644
index 0000000..380808e
--- /dev/null
+++ b/AlgoDesignAndTechniqueEdxPython/sources/maxpairproduct.py
@@ -0,0 +1,18 @@
+# Uses python3
+
+bigger = 0
+biggest = 0
+
+n = int(input())
+a = [int(x) for x in input().split()]
+
+for i in range(n):
+ if a[i] > biggest:
+ bigger = biggest
+ biggest = a[i]
+ elif a[i] == biggest:
+ bigger = a[i]
+ elif a[i] > bigger:
+ bigger = a[i]
+
+print(bigger * biggest)