原创 STL vector源碼分析

vector 1.vector概述 vector和array非常類似,區別在於array是靜態空間,一旦配置就不能改變了。空間不夠之後需要換個更大的空間,這個工作需要有客戶端自己打理。vector是動態空間,內部機制會自行擴充空間來容納新

原创 637. Average of Levels in Binary Tree 104. Maximum Depth of Binary Tree

Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1:

原创 389. Find the Difference

Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s

原创 226. Invert Binary Tree

Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3

原创 485. Max Consecutive Ones

Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,1,0,1,1,1] Output:

原创 404. Sum of Left Leaves

Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two

原创 575. Distribute Candies

Given an integer array with even length, where different numbers in this array represent different kinds of candies. E

原创 557. Reverse Words in a String III

Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whit

原创 476. Number Complement

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary repr

原创 500. Keyboard Row

Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyb

原创 561. Array Partition I

Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2),

原创 653. Two Sum IV - Input is a BST

Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum

原创 538. Convert BST to Greater Tree

Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to th

原创 268. Missing Number

Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.

原创 504. Base 7

Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202" Example 2: Input: -7