LeetCode Excercise
文章平均质量分 76
Tim_WT
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[LeeCode] Insertion Sort List
Question: Sort a linked list using insertion sort. Solution: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x),原创 2013-11-16 05:23:07 · 855 阅读 · 0 评论 -
[LeetCode]Linked List Cycle II
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode *de原创 2014-04-28 00:49:19 · 800 阅读 · 0 评论 -
[LeetCode]Max Points on a Line
Question: Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 分析: 任意一条直线都可以表述为 y = ax + b 假设,有两个点(x1,y1), (x2,y2),如果他们都在这条直线上则有转载 2014-04-27 02:58:28 · 603 阅读 · 0 评论 -
[LeetCode]Linked List Cycle
Question: Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? Answer原创 2014-04-28 01:05:34 · 880 阅读 · 0 评论 -
[LeetCode]Evaluate Reverse Polish Notation
Question: Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Some examples:原创 2014-04-27 01:56:11 · 677 阅读 · 0 评论 -
[LeetCode]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-04-26 23:17:41 · 595 阅读 · 0 评论 -
[LeetCode] Reorder List
Question: 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},原创 2013-11-23 01:04:42 · 928 阅读 · 0 评论 -
[LeetCode] Binary Tree Preorder Traversal
Question: Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: R原创 2013-11-22 02:26:51 · 929 阅读 · 0 评论 -
[LeetCode] Binary Tree Postorder Traversal
Question: Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Note: Re原创 2013-11-21 22:55:58 · 860 阅读 · 0 评论 -
[LeetCode] LRU Cache
Question: 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原创 2013-11-21 01:40:06 · 1277 阅读 · 0 评论 -
[LeetCode] Implement strStr() 字符串子串
Question: Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack. Solution (C++): class Solution { public: char *s原创 2013-11-17 18:12:46 · 839 阅读 · 0 评论 -
[LeetCode]判断回文数(Palindrome Number)
题目来源:Leetcode(www.leetcode.com) Question: Determine whether an integer is a palindrome. Do this without extra space. Solution: First, the problem statement did not specify if negative in转载 2013-11-16 03:28:31 · 1211 阅读 · 0 评论 -
[LeetCode] Generate Parentheses
Question: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: "((()))", "(()())", "(())()", "(原创 2013-11-16 17:53:06 · 737 阅读 · 0 评论 -
[LeetCode] Spiral Matrix 螺旋输出矩阵
Question: Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8原创 2013-11-17 01:55:29 · 1133 阅读 · 0 评论 -
[LeetCode] Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL. 解法:游标指针从头节点向后移动,当指向尾节点时,得到链表长度len原创 2013-11-16 04:30:22 · 788 阅读 · 0 评论 -
[LeetCode]Word Break
Question: Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s = "leetcode",原创 2014-04-28 18:26:42 · 892 阅读 · 0 评论
分享