tri_e's blog

By tri_e, history, 5 years ago, In English

HOW TO SOLVE THE INEQUALITY i*(i + 1) <= n such that i is maximum possible in O(1) time complexity.is their exist any method.

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

This is the one I can think of. Solve $$$i^{2}+i-n=0$$$
So just take floor(sol) from the previous equation.
The problem is that solution involves computing square root which is not O(1).