摘要: Given an unsorted integer array, find the first missing positive integer. For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2. Your algorithm s 阅读全文
posted @ 2017-12-10 17:59 newbird2017 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 题目大意:给出n和k,找到1..n这些数组成的有序全排列中的第k个。 首先,n的全排列可以分成n组,每一组由n-1个数组成。 例如 3的全排列,分成三组: 1 2 3 和 1 3 2 2 1 3 和 2 3 1 3 1 2 和 3 2 1 每一组的个数是(n-1)!,每一组的打头的都是i 。第i组以 阅读全文
posted @ 2017-12-10 16:48 newbird2017 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://leetcode.com/problems/trapping-rain-water/description/ 思路: 1、先找到最左侧第一个高度不为0的柱子i。 2、从i+1开始向右侧找另一个柱子max。条件:要么a[max] > a[i],要么a[max] > 右侧所有。 阅读全文
posted @ 2017-12-10 13:57 newbird2017 阅读(92) 评论(0) 推荐(0) 编辑