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說明: