Time Complexity Space complexity
�
(
�
×
�
)
O(n×k)
�
(
�
×
�
)
O(n×k)
Let n be the size of the list of strings, and k be the maximum length that a single string can have.
Time Complexity
We are counting each letter for each string in a list, so the time complexity will be
�
(
�
×
�
)
O(n×k)
.
Space complexity
Since every string is being stored as a value in the dictionary whose size can be n, and the size of the string can be k, so space complexity is
�
(
�
×
�
)
O(n×k)
.