摘要: class Solution: def strToInt(self, str: str) -> int: # 去除首尾空格 str = str.strip() # 空字符串直接返回0 if not str: return 0 res, i, sign = 0, 1, 1 int_max, int_m 阅读全文
posted @ 2021-03-03 14:38 GumpYan 阅读(70) 评论(0) 推荐(0)
摘要: 1.包含min函数的栈 定义栈的数据结构,请在该类型中实现一个能够得到栈的最小元素的 min 函数在该栈中,调用 min、push 及 pop 的时间复杂度都是 O(1)。 解析: 对于普通栈的push()和pop()函数的复杂度为O(1);而获取最小值的min() 函数需要遍历整个栈,复杂度为 O 阅读全文
posted @ 2021-03-03 10:24 GumpYan 阅读(121) 评论(0) 推荐(0)