题意:给定一个由a和b构成的字符串,可以选择翻转或不翻转他的每个前缀,翻转记为1不翻转记为0,求能将字符串排序的字典序最小的操作序列 n<=1e3 思路:考虑极长的一段a [t,w] 翻转t-1与w就能把这段a移到最前面 ...
分类:
其他好文 时间:
2018-10-29 19:59:39
阅读次数:
152
Calces系列相关文章: "Calces自动实现Android组件化模块构建" 前言 屏幕适配一直是移动端开发热议的问题,但是适配方案往往在实际开发的时候会和UI提供的设计稿冲突。本文主要是基于官方推荐的配置限定符方案(Smallest Width目前Android屏幕适配的最优方案)来实现一个接 ...
分类:
其他好文 时间:
2018-10-21 21:57:33
阅读次数:
264
Given an array A of integers, for each integer A[i] we may choose any x with K ...
分类:
其他好文 时间:
2018-10-21 13:06:02
阅读次数:
87
Given a list of sorted characters letterscontaining only lowercase letters, and given a target letter target, find the smallest element in the list th ...
分类:
其他好文 时间:
2018-10-18 01:17:00
阅读次数:
132
很有意思的一道数学推理题目, 剪枝以后解法也很简洁。初看貌似需要把每个数跟其他数作比较。但排序以后可以发现情况大大简化:对于任一对元素a[i] < a[j], a[i] - k和a[j] + k 的情况可以排除, 因为会产生比原值更大的差, 所以对于原有数组的最小值min最大值max, (min - ...
分类:
其他好文 时间:
2018-10-15 14:33:35
阅读次数:
191
Given an array A of integers, for each integer A[i] we may choose any x with -K <= x <= K, and add x to A[i]. After this process, we have some array B ...
分类:
其他好文 时间:
2018-10-07 13:51:19
阅读次数:
143
Given a set of points in the plane. the convex hull of the set is the smallest convex polygon that contains all the points of it. https://www.geeksfor ...
分类:
其他好文 时间:
2018-10-05 12:10:00
阅读次数:
126
题目如下: 解题思路:简单的不能再简单的题目了,对于任意一个A[i]来说,其可能的最小的最大值是A[i]-K,最大的最小值是A[i]+K。遍历数组,求出所有元素中最大的最小值和最小的最大值,两者之差(小于零则取零)就是答案。 代码如下: ...
分类:
其他好文 时间:
2018-09-25 14:03:29
阅读次数:
109
1 class Solution 2 { 3 public: 4 int smallestRangeI(vector& A, int K) 5 { 6 int Max = INT_MIN; 7 int Min = INT_MAX; 8 for(auto d:A) 9 ... ...
分类:
其他好文 时间:
2018-09-23 13:49:26
阅读次数:
283