I started with the base case: "1". Then for each step from 2 to n, I generated the next term by reading the previous string and counting consecutive identical digits. For each run of characters, I appended the count followed by the digit to build the next term. I repeated this until I reached the nth term.
- Time: O(n * m)
- Space: O(m) where m is the length of the final result string at n
