RyanFehr / HackerRank

HackerRank solutions in Java/JS/Python/C++/C#
MIT License
1.29k stars 694 forks source link

Greedy/Sherlock and the Beast is a Diophantine equation which can be solved without loops. #240

Open jeffreydwalter opened 5 years ago

jeffreydwalter commented 5 years ago

I have implemented this solution in Go in this PR: https://github.com/RyanFehr/HackerRank/pull/239

You guys might want to update the java solution to match. :)

jeffreydwalter commented 5 years ago

I would also note that the mathematical solution is O(1), not O(n) like the currently listed solution.