@hatella Hi, Thanks for you solution first. I have a big confusion about your O(n^3). In my view, you have three nested loop, and inside your most inner loop, you used substring method which follows by O(m) where m is the length of substring. How come this stills stays O(n^3). I think it is O(n^4)

Encode String with Shortest Length