原创 LeetCode_Validate Binary Search Tree

Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The le

原创 LeetCode_Decode Ways

A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ...

原创 設計模式基礎知識

下一步在設計模式方面的計劃:鞏固並運用設計模式,鞏固:把《大話設計模式》,《.Net設計模式》,《設計模式——可複用的面向對象基礎》,《敏捷軟件開發:原則、模式與實踐》這些書再結合起來系統的看一看,當然還會去買一些我手頭上沒有的關於設計模

原创 DP:segment string

Segment a long string into a set of valid words using a dictionary. Return the maximum number  of the subwords. 此題出自fac

原创 LeetCode_Rotate Image

You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Coul

原创 LeetCode_Jump Game II

Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element i

原创 LeetCode_Sqrt

Implement int sqrt(int x). Compute and return the square root of x. class Solution { public: int sqrt(int x) {

原创 LeetCode_Permutation Sequence

The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in o

原创 LeetCode_Wildcard Matching

Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any s

原创 LeetCode_Combination Sum

Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate

原创 LeetCode_Add Binary

Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100"class So

原创 LeetCode_Can Jump

Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element

原创 LeetCode_Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water i

原创 LeetCode_Plus One

Given a number represented as an array of digits, plus one to the number. class Solution { public: vector<int> plus

原创 遞歸將二叉樹轉換爲雙向鏈表

總體思路是遞歸,將二叉樹轉換爲記錄了頭尾指針的雙向鏈表,函數如下 void convertTreeToListHelp(TreeNode *root, TreeNode *&head, TreeNode *&tail) { head