classSolution:defcombinationSum(self, candidates: List[int], target:int)-> List[List[int]]:ans =[]path =[]defdfs(i:int, left:int)->None:if left ==0:# 找到一個合法組合ans.append(path.copy())returnif i ==len(candidates)or left <0:return# 不選dfs(i +1, left)# 選path.append(candidates[i])dfs(i, left - candidates[i])path.pop()# 恢復現場dfs(0, target)return ans
二、22. 括號生成
代碼
classSolution:defgenerateParenthesis(self, n:int)-> List[str]:m = n *2# 括號長度ans =[]path =['']* m # 所有括號長度都是一樣的 m# i = 目前填了多少個括號# open = 左括號個數,i-open = 右括號個數defdfs(i:int,open:int)->None:if i == m:# 括號構造完畢ans.append(''.join(path))# 加入答案returnifopen< n:# 可以填左括號path[i]='('# 直接覆蓋dfs(i +1,open+1)# 多了一個左括號if i -open<open:# 可以填右括號path[i]=')'# 直接覆蓋dfs(i +1,open)dfs(0,0)return ans
三、79. 單詞搜索(中等)
代碼
classSolution:defexist(self, board: List[List[str]], word:str)->bool:m, n =len(board),len(board[0])defdfs(i:int, j:int, k:int)->bool:if board[i][j]!= word[k]:# 匹配失敗returnFalseif k ==len(word)-1:# 匹配成功!returnTrueboard[i][j]=''# 標記訪問過for x, y in(i, j -1),(i, j +1),(i -1, j),(i +1, j):# 相鄰格子if0<= x < m and0<= y < n and dfs(x, y, k +1):returnTrue# 搜到了!board[i][j]= word[k]# 恢復現場returnFalse# 沒搜到returnany(dfs(i, j,0)for i inrange(m)for j inrange(n))
使用 Spring Boot 快速構建企業微信 JS-SDK 權限簽名后端服務
本篇文章將介紹如何使用 Spring Boot 快速構建一個用于支持企業微信 JS-SDK 權限校驗的后端接口,并提供一個簡單的 HTML 頁面進行功能測試。適用于需要在企業微信網頁端使用掃一掃、定位、錄音等接口的…
中國網站:FTDIChip- 首頁 UMFT4222EV-D UMFT4222EV-D - FTDI 可以下載Datasheet。 UMFT4222EVUSB2.0 to QuadSPI/I2C Bridge Development Module Future Technology Devices International Ltd. The UMFT4222EV is a development module which uses FTDI’s FT4222H…