What is the time complexity for this code?

int getans(int n)
ans=0
for( lv=1; lv*lv <=n ; lv++ )
inner_lv = n
while( inner_lv > 0 )
inner_lv- = lv
ans++
return ans

hello @nidhigupta847 i think time complexity should be less than route(n)*n .

The options are O(n square), O(n), O(n log n), O(log n)

hey @nidhigupta847 n*log(n) will be the correct option .
Happy Learning !!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.