摘要: The set contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n 阅读全文
posted @ 2017-04-06 21:00 aiterator 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 作用: + 1.知道一个序列的所有成员,可以很快得到这个序列的第k大序列(按字典序排序) + 2.给定一个序列,很快可以算出所给序列的大小(按字典序排序),常用于状态压缩 将含有n个元素的序列转换成一个数字(字典序大小) 公式 。 对于 ,代表当前元素在所有元素中是第 大的数字。(下标从 开始) 例 阅读全文
posted @ 2017-04-06 20:58 aiterator 阅读(162) 评论(0) 推荐(0) 编辑
摘要: Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example, Given n = , You should return the followi 阅读全文
posted @ 2017-04-06 17:09 aiterator 阅读(101) 评论(0) 推荐(0) 编辑
摘要: Given a set of non overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initia 阅读全文
posted @ 2017-04-06 16:45 aiterator 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 描述 一只木桶能盛多少水,并不取决于桶壁上最高的那块木板,而恰恰取决于桶壁上最短的那块。 已知一个木桶的桶壁由N块木板组成,第i块木板的长度为Ai。 现在小Hi有一个快捷修补工具,每次可以使用修补工具将连续的不超过L块木板提高至任意高度。 已知修补工具一共可以使用M次(M L using names 阅读全文
posted @ 2017-04-06 15:20 aiterator 阅读(291) 评论(0) 推荐(0) 编辑
摘要: Given a collection of intervals, merge all overlapping intervals. For example, Given , , , , return , , . + 按开始位置大小排序 + 循环数组;如果当前区间的开始位置大于上一个区间的结束位置,将 阅读全文
posted @ 2017-04-06 13:37 aiterator 阅读(83) 评论(0) 推荐(0) 编辑