原创 LeetCoed 5383. 給 N x 3 網格圖塗色的方案數

5383. 給 N x 3 網格圖塗色的方案數 分類:ABA, ABC各6種,每個ABA可與2ABC+3ABA結合, 每個ABC可與2ABC+2ABA結合 class Solution: def numOfWays(self,

原创 平衡二叉樹、B樹(B-樹)、B+樹

平衡二叉樹 中序遍歷是從小到大,二分查找。 B樹(B-樹) 不是什麼B減樹好吧。 多路查找,可以是二叉、三叉等等 每一個節點都有(key、data-point、next-point)關鍵字、數據、子節點指針。 枝節點數ceil(m/2)-

原创 面試題 04.06. 後繼者

面試題 04.06. 後繼者 思路:中序遍歷,第一個大於p->val的就是答案。實在不會,用vector存中序遍歷的TreeNode,一個個找。 class Solution { public: TreeNode* inorde

原创 LeetCode 5382. HTML 實體解析器

5382. HTML 實體解析器 class Solution: def entityParser(self, text: str) -> str: text = text.replace('"', '

原创 面試題 03.06. 動物收容所

面試題 03.06. 動物收容所 思路:隊列,記錄貓和狗,all記錄當前最老的是貓還是狗 class AnimalShelf { public: queue<vector<int> > cat, dog; vector<

原创 LeetCode 912. 排序數組

912. 排序數組 class Solution { public: vector<int> sortArray(vector<int>& nums) { sort(nums.begin(), nums.end(

原创 面試題 04.01. 節點間通路

面試題 04.01. 節點間通路 注意是有向圖,用鄰接表代替圖,dfs或者bfs都可 class Solution { public: bool findWhetherExistsPath(int n, vector<vecto

原创 LeetCode 1111. 有效括號的嵌套深度

1111. 有效括號的嵌套深度 思路:我們只需要把奇數層的 ( 分配給 A,偶數層的 ( 分配給 B 即可 //'(' 時奇數爲1,偶數爲0 class Solution { public: vector<int> maxDep

原创 LeetCode 5380. 數組中的字符串匹配

5380. 數組中的字符串匹配 python 字符串長度排序 class Solution: def stringMatching(self, words: List[str]) -> List[str]: re

原创 LeetCode 5381. 查詢帶鍵的排列

5381. 查詢帶鍵的排列 思路:鏈表 class Solution: def processQueries(self, queries: List[int], m: int) -> List[int]: res

原创 面試題 04.04. 檢查平衡性

面試題 04.04. 檢查平衡性 計算子樹的高度差<2,一次遍歷的話出現不平衡直接返回-1 /** * Definition for a binary tree node. * struct TreeNode { * in

原创 面試題 04.03. 特定深度節點鏈表

面試題 04.03. 特定深度節點鏈表 思路:層次遍歷 /** * Definition for a binary tree node. * struct TreeNode { * int val; * Tree

原创 從imdb爬取ml-100k的電影封面

從imdb爬取ml-100k的電影封面 ml-100k:數據集,只用到了./ml-100k/u.item result: 電影封面 電影id.jpg,可以用u.item找到id->電影名稱對應關係 所用到的庫 import pan

原创 二分搜索代碼

#include<bits\stdc++.h> using namespace std; int bin_search(vector<int> &nums, int target){ int left=0; int right=nu

原创 Effective Python筆記

第一章:用Pythonic方式來思考 第2條 PEP8 《Python Enhancement Proposal #8》8號Python增強提案。 空白:①4個空格代表tab ②每行<=79字符 ③分行後加4個空格 ④類中方法空1