LeetCode
文章平均质量分 50
天生就蠢
失足入银行
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Reverse Words in a String
Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click to show clarification.Clarification:What constitutes原创 2014-10-22 12:50:16 · 421 阅读 · 0 评论 -
Find Minimum in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exists in原创 2014-10-16 21:45:13 · 355 阅读 · 0 评论 -
Binary Tree Postorder Traversal
Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recursive solut原创 2014-10-30 13:45:45 · 347 阅读 · 0 评论 -
LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if原创 2014-10-30 10:28:27 · 454 阅读 · 0 评论 -
Sort List
Sort a linked list in O(n log n) time using constant space complexity.单链表排序,要求O(n原创 2014-10-29 23:18:34 · 388 阅读 · 0 评论 -
Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].Note: Recursive soluti原创 2014-10-30 13:46:39 · 341 阅读 · 0 评论 -
Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?经典的快慢指针class Solution {public: bool hasCycle(ListNode *head) { Li原创 2014-10-30 21:55:52 · 326 阅读 · 0 评论 -
Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [原创 2014-11-16 21:38:07 · 324 阅读 · 0 评论 -
Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to原创 2014-10-30 17:15:58 · 287 阅读 · 0 评论 -
Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total numb原创 2014-11-15 20:39:04 · 348 阅读 · 0 评论 -
Insertion Sort List
Sort a linked list using insertion sort.单链表插入排序,没啥好说的class Solution {public: ListNode * pickMin(ListNode * & head){ ListNode * mins = head, *cur = head; while(cur){原创 2014-10-29 23:29:55 · 269 阅读 · 0 评论 -
Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),原创 2014-11-13 23:49:32 · 366 阅读 · 0 评论 -
Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?DP最简单的题目原创 2014-11-13 23:03:38 · 347 阅读 · 0 评论 -
Evaluate Reverse Polish Notation
计算逆波兰原创 2014-10-22 14:35:04 · 363 阅读 · 0 评论 -
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.找一个二维图原创 2014-10-22 16:09:54 · 387 阅读 · 0 评论 -
Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the largest pr原创 2014-10-22 11:21:11 · 397 阅读 · 0 评论
分享