LeetCode
文章平均质量分 62
飞鸟Mu
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Permutation II @leetcode
转自: Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1], a转载 2014-07-16 23:58:32 · 645 阅读 · 0 评论 -
Sort List @leetcode
题目:https://oj.leetcode.com/problems/sort-list/ Sort a linked list in O(n log n) time using constant space complexity.原创 2014-08-21 00:16:40 · 537 阅读 · 0 评论 -
leetcode || sortlist
题目:sort a linked list in O(n log n) time using constant space complexity 思路: O(nlogn)实现链表排序,选择余地之后快速、合并、以及堆排序。 堆的空间是O(n),因此只有前两种是可以考虑的。 这道题目采用快速排序会TLE,合并排序就不会,应该是快排的交换次数太多。原创 2014-06-14 17:20:49 · 665 阅读 · 0 评论 -
leetcode || Single Number
Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using ext原创 2014-06-25 21:48:14 · 539 阅读 · 0 评论 -
Permutation Sequence @leetcode
这道题其实有很强的规律可循。首先,n个元素的排列总数是n!。在下面的分析中,让k的范围是0 可以看到一个规律,就是这n!个排列中,第一位的元素总是(n-1)!一组出现的,也就说如果p = k / (n-1)!,那么排列的最开始一个元素一定是arr[p]。 这个规律可以类推下去,在剩余的n-1个元素中逐渐挑选出第二个,第三个,...,到第n个元素。程序就结束。 转载自:http://bl转载 2014-07-16 21:58:09 · 608 阅读 · 0 评论 -
leetcode || Pascal's Triangle
Question: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] Answer:原创 2014-06-25 21:41:34 · 563 阅读 · 0 评论 -
[LeetCode]Linked List Cycle & Linked List Cycle II——单链表中的环
题目要求 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? 如何判断一个单链表中有环? Linked List Cycle II Given a linke转载 2014-06-22 20:57:42 · 661 阅读 · 0 评论 -
Leetcode || 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-06-28 23:10:45 · 527 阅读 · 0 评论 -
leetcode||Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space? Answer: cla原创 2014-06-25 21:42:52 · 550 阅读 · 0 评论 -
leetcode||Single Number II
Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without usi原创 2014-06-25 21:46:56 · 675 阅读 · 0 评论 -
Populating Next Right Pointers in Each Node
题目: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next rig原创 2015-10-23 16:03:08 · 661 阅读 · 0 评论
分享