The naive solution reports O(n^3) time while the optimal solution reports O(1) time. The former uses variable notation and assumes an infinitely large input, while the latter assumes an input of constant size, so the comparison doesn’t strike me as meaningful. To create a meaningful comparison, I recommend assuming infinitely large input and using variables in the complexity analysis. Here we could use n to describe the total input length, or even better, break things down into the max length of an octet (x) and number of octets (y) s.t. xy = n.
Course: Grokking Coding Interview Patterns in Python - Learn Interactively
Lesson: Solution: Restore IP Addresses - Grokking Coding Interview Patterns in Python