原创 leetcode_題解_Maximum Depth of Binary Tree_簡單題

遞歸函數調用DFS(沒有用顯式棧,居然AC了) /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left;

原创 leetcode_題解_path sum 2

Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example:Giv

原创 leetcode_length of last word_easy

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last wor

原创 數據結構--線性表順序實現

主要參考嚴老師那本教材: #include <stdio.h> #include <malloc.h> #define LIST_INIT_SIZE 100//線性表存儲空間初始分配量 #define LISTINCREMENT 10/

原创 leetcode_題解_Palindrome Number _easy_迴文數(空間O(1))

題目:判斷是否是迴文數(空間要求不能用額外的) 注意:負數不是迴文數 class Solution { public: bool isPalindrome(int x) { if(x<0)

原创 leetcode_Valid Sudoku and Sudoku Solver (數獨遊戲) _easy

下面兩個題目參考了戴同學的題解的思路。 Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could

原创 leetcode_Binary Tree Level Order Traversal _easy

Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level)

原创 leetcode_Permutations II _hard_暴力枚舉法--回溯法

Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,[1,

原创 leetcode_same tree_easy

Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if

原创 leetcode_Symmetric Tree_判斷二叉樹鏡像對稱_easy_方法

/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right;

原创 leetcode_Intersection of Two Linked Lists_easy_主要是方法

Write a program to find the node at which the intersection of two singly linked lists begins. For example, the follow

原创 leetcode_題解_single number_小技巧

Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm sh

原创 八皇后問題--遞歸調用

參考了算法競賽入門經典那本書p125: #include <stdio.h> const int n=4; int tol=0; int arr[n]; //輸出某個解 void print_res(int arr[],int n)

原创 leetcode_題解_path sum_easy

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along

原创 leetcode_Roman to Integer_easy_可以看看方法

Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 主要弄清楚羅馬數