
LeetCode
文章平均质量分 81
SammyLan
当你的才华还撑不起你的野心时,那你就应该静下心来学习。
展开
-
Search a 2D Matrix II
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers in each column are sorted in ascending from top to bottom.原创 2015-07-25 14:59:04 · 420 阅读 · 0 评论 -
Ugly Number II
Ugly Number IIclass Solution {public: int nthUglyNumber(int n) { vec.reserve(n); vec.push_back(1); int i2 = 0; int i3 = 0; int i5 = 0; for(int i原创 2015-09-13 20:14:27 · 619 阅读 · 0 评论 -
Different Ways to Add Parentheses
Different Ways to Add ParenthesesGiven a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid ope原创 2015-07-30 15:14:17 · 641 阅读 · 0 评论 -
Palindrome Linked List
Palindrome Linked ListGiven a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?以下是使用Length的版本class Solution {public: bo原创 2015-07-27 17:12:34 · 594 阅读 · 0 评论 -
Binary Search Tree Iterator
Binary Search Tree IteratorImplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest num原创 2015-07-27 16:44:51 · 463 阅读 · 0 评论 -
Kth Smallest Element in a BST
Kth Smallest Element in a BSTGiven a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST's total e原创 2015-07-27 16:39:52 · 452 阅读 · 0 评论 -
Search a 2D Matrix
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row is greater than the last integer of the previous row.原创 2015-07-25 15:50:02 · 400 阅读 · 0 评论 -
Sliding Window Maximum
Sliding Window MaximumGiven an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Ea原创 2015-07-25 15:13:20 · 455 阅读 · 0 评论 -
Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.getMin() -- Retrieve the minimum elemen原创 2015-07-25 15:05:48 · 457 阅读 · 0 评论 -
微软2016校园招聘9月在线笔试-题目3 : Fibonacci
题目3 : Fibonacci时间限制:10000ms单点时限:1000ms内存限制:256MB描述Given a sequence {an}, how many non-empty sub-sequence of it is a prefix of fibonacci sequence.A sub-sequence is a sequenc原创 2015-09-30 14:59:59 · 1538 阅读 · 1 评论