- 博客(10)
- 收藏
- 关注
原创 [LeetCode]Summary Ranges
Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"]. class Solution { public: vector summaryRanges
2015-06-29 11:57:53 431
原创 [LeetCode]House Robber II
After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, all houses at this place are arranged in a ci
2015-06-16 21:19:08 418
原创 [LeetCode]Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia: This problem was inspired by this original tweet by Max Howe
2015-06-12 18:23:38 623
原创 [LeetCode]Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. [LeetCode Source] 思路:对每一个节点求和其他节点的斜率,用hash_map统计斜率相同的点数。时间O(N^2),空间O(N)。应该有更简单可以在O(1)空间的算法,暂时没想出
2015-06-11 19:58:29 556
原创 [LeetCode]Implement Stack using Queues
Implement the following operations of a stack using queues. push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.empty() -- Return whet
2015-06-11 15:59:22 704
原创 [LeetCode]Rectangle Area
Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined by its bottom left corner and top right corner as shown in the figure. Assume that the tota
2015-06-08 15:55:45 673
原创 [LeetCode]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 fille
2015-06-06 20:57:21 1319
原创 [LeetCode]Maximal Square
Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 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 1 0
2015-06-06 14:54:47 349
原创 [LeetCode]N-Queens
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle.
2015-06-03 23:52:08 349
原创 [LeetCode]Word Ladder
Given two words (beginWord and endWord), and a dictionary, find the length of shortest transformation sequence from beginWord toendWord, such that: Only one letter can be changed at a timeEach inte
2015-06-02 19:55:11 409
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人