多回合AI代理实战:用Genkit与本地模型搭建智能客服助手
2026/9/30 10:22:39
84 柱状图中最大的矩形
class Solution: def largestRectangleArea(self, heights: list[int]) -> int: n=len(heights) left=[-1]*n right=[n]*n st=[] for i,h in enumerate(heights): while st and h<=heights[st[-1]]:st.pop() if st:left[i]=st[-1] st.append(i) st.clear() for i in range(n-1,-1,-1): h=heights[i] while st and h<=heights[st[-1]]:st.pop() if st:right[i]=st[-1] st.append(i) ans=0 for i,j,h in zip(left,right,heights): ans=max(ans,(j-i-1)*h) return ans198 打家劫舍
class Solution: def rob(self, nums: List[int]) -> int: f0=f1=0 for x in nums: f0,f1=f1,max(f1,f0+x) return f1118 杨辉三角
class Solution: def generate(self, numRows: int) -> list[list[int]]: c=[[1]*(n+1) for n in range(numRows)] for i in range(2,numRows): for j in range(1,i): c[i][j]=c[i-1][j]+c[i-1][j-1] return c