We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
as we know geometric progression is a, a*r, (a*r)*r so on.. here we are using t2 and t3 to track a*r and (a*r)*r respectively .
in t2 we check if element of form a*r is there or not. Similarly in t3 we check if (a*r)*r is there or not.
+ t3.getOrDefault(a*r, 0L) + t2.get(a)) - part track the no# tupple present .. smart coding!!
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Count Triplets
You are viewing a single comment's thread. Return to all comments →
as we know geometric progression is a, a*r, (a*r)*r so on.. here we are using t2 and t3 to track a*r and (a*r)*r respectively .
in t2 we check if element of form a*r is there or not. Similarly in t3 we check if (a*r)*r is there or not. + t3.getOrDefault(a*r, 0L) + t2.get(a)) - part track the no# tupple present .. smart coding!!