Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Time Complexity Struggle

maagjoel1

Aug 31, 2023

I am struggling to understand the time complexity of this solution. Specifically with why M = log(N +1). Where does this come from?

0

0

Comments
Comments
Z
zafeiropoulou.dimitra@gmail.com 2 years ago

plus one

Shubham Vora
Shubham Voraa year ago

Here's a brief explanation:

  • findSquareSum(num) Complexity: For a number num, calculating the sum of squares of its digits takes O(log N) time, where N is the number. This is because num has log10(N) digits.

  • Cycle Detection: The function eve...

On this page