So I started doing the Coursera course for Algorithsm, mostly since I was spending a lot of time on SNS and not really learning anything. I thought to might as well start with a lil programming since I have long left it tbh.
For the first week of the course, I had a very simple problem statement
In this problem, we’re given an array, or a sequence of n numbers. And our goal is to find a number which can be obtained by multiplying some two numbers from this sequence.
So there would be two inputs when you run the program like –
1 2 3
The output should be the largest number, which is a multiplication of the pair, in this case it would be 6.
For another sample input
-10000 -20000 10 20
The output would be 20000000 because multiplying two negative numbers gives you a positive number. I was able to solve it however only after doing a stress test with multiple implementations and matching the results of each one. It really did take a lot of time to reach the answer or maybe I wasted a lot of time in not going to the stress test option first.
Below is a working and 100% successfuly solution. Do try it out and let me know if you guys have any problems running it.