You are viewing a single comment's thread. Return to all comments →
Very Simple . We have to care about the only 2 and 1. Because other numbers , like 3,4 will give (3+4)/(3*4)= 0 .So don't care about them .
All one(1) among them , make value 2 because (1+1)/(1*1) = 2.
All one(1) with other numbers, make value 1 because like for 3 (1+3)/(1*3)= 1
All two among them will make 1 . Because for 2 (2+2)/(2*2)=1 .
So only count them and give the result
My solution with comments line
https://github.com/joy-mollick/Problem-Solving-Solutions-Math-Greedy-/blob/master/HackerRank-Pairwise%20Sum%20and%20Divide.cpp
Seems like cookies are disabled on this browser, please enable them to open this website
Pairwise Sum and Divide
You are viewing a single comment's thread. Return to all comments →
Very Simple . We have to care about the only 2 and 1. Because other numbers , like 3,4 will give (3+4)/(3*4)= 0 .So don't care about them .
All one(1) among them , make value 2 because (1+1)/(1*1) = 2.
All one(1) with other numbers, make value 1 because like for 3 (1+3)/(1*3)= 1
All two among them will make 1 . Because for 2 (2+2)/(2*2)=1 .
So only count them and give the result
My solution with comments line
https://github.com/joy-mollick/Problem-Solving-Solutions-Math-Greedy-/blob/master/HackerRank-Pairwise%20Sum%20and%20Divide.cpp