Terrible LeetCode in Kotlin:

Опубликовано: 24 Июнь 2026
на канале: Personal Finance with Raymond
38
2

Another day, another LeetCode question (for now). Today, I'm running through #394 Decode String. The problem provides an string where we are given a frequency integer and characters surrounded by square brackets. The expected output is the decoded string.

This problem I felt had a natural recursive feeling to it, where you could recurse on the subproblem at each of those subsections (number, characters enclosed in brackets). I decided to go that route, which would build up and return a string, which would then be repeated the number of times appropriate. I think this algorithm runs in O(n) time and space (the space due to the stack), but I'm honestly not as confident about this one.

I work in Kotlin as my LeetCode programming language because my current focus is on Android app development. Kotlin is interoperable with Java, so the solution should be relatively similar albeit with some more boilerplate checks for nulls and such.

Current Grind:
Grind75 list, 22 weeks/16 hours per week, [100/169] (wow)
(https://www.techinterviewhandbook.org...)

Chapters:
00:00 - Problem discussion
02:22 - Coding Begins (Recursion)