原创 改善代碼質量編程規範 - 學習總結

Table of Contents 命名與註釋 命名 範圍 原則建議 註釋 註釋應該寫什麼 原則建議 代碼風格 類、函數大小 代碼長數 空行分割單元塊 類成員的排列順序 編程技巧 將複雜代碼片分割爲小單元塊 避免函數參數過多 建議 函數設

原创 LeetCode(85) 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 a

原创 判斷樹T2是否爲T1的子樹

題目 你有兩顆非常大的二叉樹:T1,有幾百萬個節點;T2有幾百個節點。 設計一個算法,判斷T2是否爲T1的子樹。 如果T1有一個節點n,其子樹與T2一模一樣,則T2爲T1的子樹。也就是說,從節點n 處把樹砍斷,得到的樹與T2完全相同。

原创 二叉樹和爲某一值的路徑

題目 題目:二叉樹和爲某一值的路徑 描述:輸入一顆二叉樹和一個整數,打印出二叉樹中結點值的和爲輸入整數的所有路徑。 路徑定義爲從樹的根結點開始往下一直到葉結點所經過的結點形成一條路徑。 延伸: 若要求路徑不一定非得從二叉樹的根節點或葉

原创 二叉樹中插入節點的遞歸與非遞歸

題目  給定一棵二叉查找樹和一個新的樹節點,將節點插入到樹中。 你需要保證該樹仍然是一棵二叉查找樹。 樣例 給出如下一棵二叉查找樹,在插入節點6之後這棵二叉查找樹可以是這樣的: 2 2 / \

原创 Leetcode 965. Univalued Binary Tree

題目 A binary tree is univalued if every node in the tree has the same value. Return true if and only if the given tree i

原创 Leetcode 961. N-Repeated Element in Size 2N Array

題目 In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeated N times. Retur

原创 Leetcode 971. Flip Binary Tree To Match Preorder Traversal

題目 Given a binary tree with N nodes, each node has a different value from {1, ..., N}. A node in this binary tree can b

原创 LeetCode 970. Powerful Integers

題目 Given two non-negative integers x and y, an integer is powerful if it is equal to x^i + y^j for some integers i >= 0

原创 LeetCode 771. Jewels and Stones

題目 You're given strings J representing the types of stones that are jewels, and S representing the stones you have.  Ea

原创 中國電信 CTExcel - 親測境外首選電話卡(推薦碼:SHQL)

官網 中國電信美洲公司CTExcel https://www.ctexcel.us/index_pc.jsp?language=zh 微信公衆號 - “中國電信美洲公司” 親測好用 因爲公司內部調動,12月要去美國工作。機緣巧合,看到了網

原创 LeetCode(617) Merge Two Binary Trees

題目 Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees ar

原创 C++實現單例模式

單例模式 單例模式,可以說設計模式中最常應用的一種模式了,據說也是面試官最喜歡的題目。但是如果沒有學過設計模式的人,可能不會想到要去應用單例模式,面對單例模式適用的情況,可能會優先考慮使用全局或者靜態變量的方式,這樣比較簡單,也是沒學

原创 LeetCode(383)Ransom Note

題目 Given
 an 
arbitrary
 ransom
 note
 string 
and 
another 
string 
containing 
letters from
 all 
the 
magazines,


原创 LeetCode(87) Scramble String

題目 Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively