原创 Leetcode_num12_Search Insert Position

題目: Given a sorted array and a target value, return the index if the target is found. If not, return the index where

原创 leetcode_num118_Pascal's Triangle

Given numRows, generate the first numRows of Pascal's triangle. class Solution { public: vector<vector<int> > gen

原创 leetcode_num190_Reverse Bits

Reverse bits of a given 32 bits unsigned integer. 歸併法 class Solution { public: uint32_t reverseBits(uint32_t n) {

原创 atoi函數編寫

#include<iostream> #include<string> using namespace std; int ai(const char *p){ bool negflag = false; int rs = 0; if

原创 leetcode_num168&171_excel title&number

Given a positive integer, return its corresponding column title as appear in an Excel sheet. class Solution { public:

原创 排序算法總結(二)歸併法

遞歸法 #include<iostream> using namespace std; void Merge(int r[],int r1[],int b,int m,int e){ int i=b; int j=m+1; int

原创 Leetcode_num10_Populating Next Right Pointers in Each Node

題目: Populate each next pointer to point to its next right node. If there is no next right node, the next pointer shou

原创 中文詞性標註解釋一覽表

Definitions of Chinese Part-of-Speech 中文詞性標註(33)   [1]     AD    副詞  Adverbs [2]     AS    語態詞  --- 了 [3]     BA 

原创 Leetcode_num14_Roman to Integer

題目: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 題目意

原创 Leetcode_num13_Climbing Stairs

題目: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps

原创 Leetcode_num8_Binary Tree Preorder Traversal

題目:Given a binary tree, return the preorder traversal of its nodes' values. 此題即爲二叉樹的前序遍歷,遞歸的方法很簡單:先節點再左子樹再右子樹;迭代的方法可以利

原创 Leetcode_num9_Binary Tree Inorder Traversal

同num8一樣,此題考查的是二叉樹的中序遍歷,即先左子樹再節點再右子樹、 使用迭代法時,採用將節點和左子樹均壓入棧的方法,當左子樹爲NULL時,將top節點彈出,並存入結果列表,將next指針指向該節點的右子樹 代碼如下: /** *

原创 Leetcode_num15_Maximun Subarray

題目:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For exam

原创 leetcode_num112_Path Sum

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 t

原创 Leetcode_num11_Remove Duplicates from Sorted List

題目: Given a sorted linked list, delete all duplicates such that each element appear only once. 這道鏈表的題也比較簡單,目標是爲了去重,只是需要