原创 [數據結構]C++實現二叉樹及其遍歷 1. BST的結構 2. 前序、中序、後序遍歷的遞歸實現 3. 前序、中序、後序遍歷的非遞歸實現 4. 層序遍歷

溫故而知新。本文將回顧二叉搜索樹的基本知識,並用C++將它的三種depth-first search: 前序遍歷、中序遍歷和後序遍歷,以及一種breath first search: 層序遍歷算法分別實現出來。 1. BST的結構 首先,我

原创 [LeetCode] LRU和LFU詳解之一 LRU的設計與實現

LRU (Least recently used,最近最少使用 ) 和 LFU (Least frequently used,最不經常使用)是兩種經典的cache管理算法。其主要差別在於其核心思想: LRU:如果數據最近被訪問過,那麼將來

原创 [LeetCode] Largest Rectangle in Histogram 直方圖中最大的矩形

題目描述: Given *n* non-negative integers representing the histogram's bar height where the width of each bar is 1, find th

原创 [LeetCode] Maximal Rectangle 最大矩形

題目描述: Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its ar

原创 [Leetcode] Maximal Square最大正方形

題目描述: Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.

原创 [Leetcode] Implement Trie (Prefix Tree) 前綴表達樹

前綴表達樹又稱字典樹,是一種多叉樹結構,主要用於快速搜索。本題要求設計前綴表達樹,實現insert, search, 和 startsWith三個方法。 Implement a trie with insert, search, and s

原创 [leetcode專題]--Tree(#98-#104)

98. Validate Binary Search Tree 題目描述: Given a binary tree, determine if it is a valid binary search tree (BST). Assume