题目描述: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. 解题思路: 每次在上一个list前面插入1,然后后面的每两个间相加赋值给前一
分类:
编程语言 时间:
2016-01-27 22:55:09
阅读次数:
226
215. Kth Largest Element in an Array
My Submissions
Question
Total Accepted: 38315 Total
Submissions: 123284 Difficulty: Medium
在一个未排序的数组中找到第k大的元素,注意此言的第k大就是排序后的第k大的数,
注意:给定k总是安全有效的...
分类:
其他好文 时间:
2016-01-27 10:55:08
阅读次数:
175
翻译给定一个索引K,返回帕斯卡三角形的第K行。例如,给定K=3,
返回[1,3,3,1]。注释:
你可以改进你的算法只用O(k)的额外空间吗?原文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 optimiz...
分类:
其他好文 时间:
2016-01-23 13:16:29
阅读次数:
186
---恢复内容开始---题意:给出一个序列和操作次数, 每次操作修改一个位置的数 或者 询问一个区间第k小的数分析:单点修改可以考虑线段树, 区间排名可以用平衡树所以线段树+Treap用一颗线段树将序列划分 每颗Treap中插入的是对应区间的数在每个数加入时, 顺便将该数插入线段树中包含该位置的那些...
分类:
其他好文 时间:
2016-01-22 21:49:59
阅读次数:
218
You are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a ne...
分类:
其他好文 时间:
2016-01-20 22:20:39
阅读次数:
181
https://leetcode.com/problems/count-of-smaller-numbers-after-self/You are given an integer array nums and you have to return a new counts array. The c...
分类:
其他好文 时间:
2016-01-19 06:54:20
阅读次数:
170
问题:找出二叉搜索树种第 k 小的元素。 一个深度遍历的应用。使用递归、或者借助栈都可以实现深度遍历。本文代码使用递归实现。
分类:
其他好文 时间:
2016-01-10 11:35:01
阅读次数:
154
题目第k大元素在数组中找到第k大的元素样例给出数组[9,3,2,4,8],第三大的元素是4给出数组[1,2,3,4,5],第一大的元素是5,第二大的元素是4,第三大的元素是3,以此类推注意你可以交换数组中的元素的位置挑战要求时间复杂度为O(n),空间复杂度为O(1)解题理论快速排序的思想,每次都减半...
分类:
其他好文 时间:
2016-01-03 23:58:50
阅读次数:
412
Given 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 ...
分类:
其他好文 时间:
2015-12-19 13:44:38
阅读次数:
163
Kth Largest Element in an ArrayTotal Accepted:32668Total Submissions:109273Difficulty:MediumFind thekth largest element in an unsorted array. Note tha...
分类:
其他好文 时间:
2015-12-18 18:25:38
阅读次数:
117