1linePython
1.0.0
一系列单线python回答了一些在线代码挑战。
当我向Shinez1997挑战以在BinarySearch.com上仅使用一行Python代码来解决代码问题时,这个存储库的想法就来了。在编码的各个方面,他都比我更好,这是我以某种方式击败他的唯一方式。
return相同。例子:
# functools is imported by default
class Solution : # default by online judge
def minAddToMakeValid ( self , s : str ) -> int : # default by online judge
# answer fit in one line
return len ( functools . reduce ( lambda c1 , c2 : c2 if not c1 else c1 [: - 1 ] if c2 == ")" and c1 [ - 1 ] == "(" else c1 + c2 , s )) if s else len ( s )如果您想为此列表做出贡献,请使用此模板:
来源:链接
描述:
描述和示例
回答:
# Code in Python说明: