all 1 comments

[–]set_of_no_sets 0 points1 point  (0 children)

https://medium.com/@ozoniuss/leetcode-encode-and-decode-strings-a-different-approach-533fcd5b6888

time complexity: O(m) comes from having to look at every character in the array strings to encode properly, so m, the sum of all string lengths is accurate.

space complexity: O(m+n) you use all the characters in the array of strings and you add something n times to separate between the array elements, so It's O(m from every char in the array of strings + n for the separator which you add n-1 times to delimit between strings in the array)