原创 LeetCode總結,回溯法小結
一,回溯法思想 一般教科書概念上的講解 回溯算法實際上一個類似枚舉的搜索嘗試過程,主要是在搜索嘗試過程中尋找問題的解,當發現已不滿足求解條件時,就“回溯”返回,嘗試別的路徑。 回溯法是一種選優搜索法,按選優條
原创 54 / 59 Spiral Matrix( I / II )
Total Accepted: 61182 Total Submissions: 268396 Difficulty: Medium Given a matrix of m x n elements (m rows, n
原创 數字圖像處理,一種簡單的顏色平衡算法
對於黯淡的彩色圖像調節效果......... 對於暗淡圖像的調節,灰度直方圖基本均勻碾平: 對於過度飽和圖像的效果,右上角展示了直返圖的效果,可以看見基本均勻碾平了: 參考代碼: #include "string" #i
原创 106. Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do
原创 223. Rectangle Area
Total Accepted: 38216 Total Submissions: 126941 Difficulty: Easy Find the total area covered by two rectilinea
原创 109 / 108 Convert Sorted ( List / Array ) to Binary Search Tree
Total Accepted: 71642 Total Submissions: 233074 Difficulty: Medium Given a singly linked list where elements a
原创 60. Permutation Sequence
Total Accepted: 56468 Total Submissions: 221337 Difficulty: Medium The set [1,2,3,…,n] contains a total of n!
原创 201. Bitwise AND of Numbers Range
題目翻譯: 0 <= m <= n <= 2147483647,求取m到n之間所有數字相與運算的結果。 分析:DONE 笨辦法,直接相與,顯然容易超時。 class Solution { public: int rangeBi
原创 48. Rotate Image
Total Accepted: 69879 Total Submissions: 199786 Difficulty: Medium You are given an n x n 2D matrix representi
原创 105. Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do
原创 114. Flatten Binary Tree to Linked List
Total Accepted: 84864 Total Submissions: 270352 Difficulty: Medium Given a binary tree, flatten it to a linked
原创 334. Increasing Triplet Subsequence
題目翻譯: 給定一個未排序的數組,返回數組中是否存在長度爲3的遞增子序列(不一定要連續)。 舉例: 返回true,如果存在I,J,K 使得,ARR [I] < ARR [J]. < ARR [K] 給定的0 ≤ I < J < K
原创 357. Count Numbers with Unique Digits
Total Accepted: 450 Total Submissions: 1077 Difficulty: Medium Given a non-negative integer n, count all numbe
原创 241. Different Ways to Add Parentheses
題目: 給定一個字符串的數字和運算符,返回所有可能括號組合的計算結果。有效的操作符爲 +,-和*。 例1 輸入:“2-1-1”。 ((2-1)-1) = 0 (2-(1-1)) = 2 輸出:[ 0,2 ] 例2 輸入:“2×4×5” (
原创 200 / 130 Number of Islands / Surrounded Regions
Total Accepted: 48411 Total Submissions: 171609 Difficulty: Medium Given a 2d grid map of '1's (land) and '0'