From 15ff94736221bfdf8c3b60457409b9c4d350aa4b Mon Sep 17 00:00:00 2001 From: Haidong Ji Date: Tue, 7 Aug 2018 20:54:17 -0500 Subject: Python 3 implementation of max pairwise product! --- .../sources/maxpairproduct.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 AlgoDesignAndTechniqueEdxPython/sources/maxpairproduct.py 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) -- cgit v1.2.3