1# Runtime: 38 ms (Top 74.6%) | Memory: 16.44 MB (Top 25.3%)234class Solution:5def removeComments(self, source: List[str]) -> List[str]:6ans, inComment = [], False7new_str = ""8for c in source:9if not inComment:10new_str = ""11i, n = 0, len(c)12# inComment, we find */13while i < n:14if inComment:15if c[i : i + 2] == "*/" and i + 1 < n:16i += 217inComment = False18continue19i += 120# not in Comment, we find /* // and common character21else:22if c[i : i + 2] == "/*" and i + 1 < n:23i += 224inComment = True25continue26if c[i : i + 2] == "//" and i + 1 < n:27break28new_str += c[i]29i += 130if new_str and not inComment:31ans.append(new_str)3233return ans