- 博客(12)
- 收藏
- 关注
原创 230. Kth Smallest Element in a BST && 530. Minimum Absolute Difference in BST
530 Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes. Example: Input: 1 \ 3 / 2 Output: 1 Explanat
2017-03-28 16:52:15 159
原创 401. Binary Watch
A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents a zero or one, with the least significant bit on
2017-03-21 12:01:00 209
原创 166. Fraction to Recurring Decimal
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in parentheses.
2017-03-12 21:18:55 190
原创 222. Count Complete Tree Nodes
Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia: In a complete binary tree every level, except possibly the last, is completely filled,
2017-03-12 10:53:45 164
原创 221. Maximal Square
Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0
2017-03-12 10:45:32 207
原创 218. The Skyline Problem
class Solution { public: vector> getSkyline(vector>& buildings) { vector> height, skyline; for(auto b : buildings){ height.push_back(make_pair(b[0], -b[2]));
2017-03-12 10:37:57 235
原创 208. Implement Trie (Prefix Tree)
Implement a trie with insert, search, and startsWith methods. trie是一棵树,用于存储字符串的,有公共前缀的字符串在一棵子树上。 class TrieNode{ public: TrieNode* next[26]; bool is_word; TrieNode(bool b=fals
2017-03-07 21:17:34 264
原创 207. Course Schedule
There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a
2017-03-07 20:19:04 163
原创 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 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9] BFS+维护一个每行
2017-03-03 10:49:31 176
原创 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 / \ 1 3 Output: 1 Example 2: Input: 1 / \ 2 3
2017-03-03 10:46:20 177
原创 450. Delete Node in a BST
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST. Basically, the deletion can be divided int
2017-03-03 10:44:40 170
原创 数据结构——树 总结篇
以后把遇到的树的问题都总结在这一篇里啦~ 1.普通的树的数据结构表示 struct TreeNode{ TYPE element;//该节点的元素 TreeNode *firstChild;//指向该节点的第一个孩子 TreeNode *nextSibling;//指向该节点的兄弟节点 }; http://blog.csdn.net/linux_ever/article/detail
2017-03-03 10:26:35 277
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人