### LeetCode题解——C/C++版

LeetCode上题目的一些解题报告，不一定是最优解。大部分题目都会用纯C编写，但有时也会用到STL。

6 已关注
69篇博文
• #### LeetCode 399 Evaluate Division（BFS）

Equations are given in the format A / B = k, where A and B are variables represented as strings, an...

2017-11-07 17:43
287
• #### LeetCode 146 LRU Cache（list+unordered_map实现LRU缓存算法）

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the f...

2017-10-28 12:17
318
• #### LeetCode 414 Third Maximum Number（set + priority_queue）

Given a non-empty array of integers, return the third maximum number in this array. If it does not e...

2017-08-29 16:58
371
• #### LeetCode 103 Binary Tree Zigzag Level Order Traversal（二叉树层序遍历）

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

2017-08-11 21:09
603
• #### LeetCode 155 Min Stack（实现具有特殊操作的栈）

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. ...

2017-08-10 13:04
440
• #### LeetCode 654 Maximum Binary Tree（构建二叉搜索树）

Given an integer array with no duplicates. A maximum tree building on this array is defined as follo...

2017-08-06 19:11
638
• #### LeetCode 304 Range Sum Query 2D - Immutable（维护二维数组的前缀和）

Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper lef...

2017-08-04 18:37
552
• #### LeetCode 303 Range Sum Query - Immutable（维护前缀和）

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusi...

2017-08-03 19:17
403
• #### LeetCode 307 Range Sum Query - Mutable（树状数组 || 线段树）

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive...

2017-07-30 21:18
523
• #### LeetCode 108 Convert Sorted Array to Binary Search Tree（二分 + 递归建树）

Given an array where elements are sorted in ascending order, convert it to a height balanced BST. ...

2017-07-24 21:26
389
• #### LeetCode 646 Maximum Length of Pair Chain（贪心）

You are given n pairs of numbers. In every pair, the first number is always smaller than the secon...

2017-07-23 13:58
674
• #### LeetCode 637 Average of Levels in Binary Tree（二叉树层序遍历）

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

2017-07-21 19:05
840
• #### LeetCode 513 Find Bottom Left Tree Value（二叉树层序遍历）

Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input: 2 ...

2017-07-19 19:49
190
• #### LeetCode 515 Find Largest Value in Each Tree Row（二叉树层序遍历）

You need to find the largest value in each row of a binary tree. Example: Input: 1 ...

2017-07-18 19:44
157
• #### LeetCode 232 Implement Queue using Stacks（利用栈实现队列）

Implement the following operations of a queue using stacks. push(x) -- Push element x to the back...

2017-07-18 18:56
267
• #### LeetCode 225 Implement Stack using Queues（利用队列实现栈）

Implement the following operations of a stack using queues. push(x) -- Push element x onto stack....

2017-07-18 13:21
896
• #### LeetCode 319 Bulb Switcher（数学Tricks）

There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every ...

2017-07-17 13:53
440
• #### LeetCode 198 House Robber（基础DP）

You are a professional robber planning to rob houses along a street. Each house has a certain amount...

2017-07-15 21:29
478
• #### LeetCode 199 Binary Tree Right Side View（二叉树层序遍历）

Given a binary tree, imagine yourself standing on the right side of it, return the values of the nod...

2017-07-14 22:41
493
• #### LeetCode 102 Binary Tree Level Order Traversal（二叉树层序遍历）

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

2017-07-13 19:51
712