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.
The solution can be found much more quickly than the editorial says due to combinatorial simplification; there is a two-line solution (that is, two lines in the query loop, one of them being the input line) that runs in O(X + Y + T) time. No Y^3 needed. A hint: https://oeis.org/A033184
I think the problem setter didn't check for an accidental identity.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Div and Span
You are viewing a single comment's thread. Return to all comments →
The solution can be found much more quickly than the editorial says due to combinatorial simplification; there is a two-line solution (that is, two lines in the query loop, one of them being the input line) that runs in O(X + Y + T) time. No Y^3 needed. A hint: https://oeis.org/A033184 I think the problem setter didn't check for an accidental identity.