Note: they say the order of the characters in the generated acronym matters, so one can’t just count frequencies. No need to overthink this solution, just store first letter of every word
in words
, and check if it’s similar to s
.
Code:
Python3
Big O Analysis
-
Runtime
The runtime complexity here is
O(N)
where N = length of listwords
. -
Memory
The memory usage is
O(N)
since we use aret
string.
— A