Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

Did anybody know the time complexity for this?

If you calculate all the string from 1 to n, the total loop num is 1 + 2 + 3 + ... + n = n(n+1)/2 So, O(n^2)

But the length of output string is not just growing linearly, O(n^2) may not be a sufficient upper bound in my view

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.