题目大意:给出n个数,要求将这n个数两两相减,把这些相减得到的数排序后,输出位置在中间的那个数解题思路:如果两两相减再排序复杂度太高,肯定超时了,不妨换另一种思路
枚举最中间的那个数,然后判断一下相减得到的数有多少个大于等于枚举的数
如何判断上面所说的那句呢,其实不用把每个数相减,只需要排序一下,然后将当前这个数 + 枚举的那个数,然后在数组中找到大于等于这个数的第一个位置(lower_boun...
分类:
其他好文 时间:
2015-05-12 23:02:28
阅读次数:
170
一.前提要了解一下lua 的string几个方法1. string库中所有的字符索引从前往后是1,2,...;从后往前是-1,-2,...2. string库中所有的function都不会直接操作字符串,而是返回一个结果string.len(s):返回字符串的长度.string.lower(s):变...
分类:
其他好文 时间:
2015-05-12 15:31:28
阅读次数:
131
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word ...
分类:
其他好文 时间:
2015-05-12 08:09:32
阅读次数:
108
题目:Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word ...
分类:
其他好文 时间:
2015-05-11 23:57:44
阅读次数:
154
题目:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.代码:class Solution {public: vect...
分类:
其他好文 时间:
2015-05-11 21:30:23
阅读次数:
206
--##字符函数,大小写处理函数
SELECT LOWER('ABcDe')
FROM dual; -- abcde,全部转换为小写
SELECT UPPER('ABcDe')
FROM dual; -- ABCDE,全部转换为大写
SELECT INITCAP('aBcDe')
FROM dual; -- Abcde,首字母大写
--##字符函数,字符串处理函数
SEL...
分类:
数据库 时间:
2015-05-11 17:57:02
阅读次数:
151
离散化
使用STL算法离散化:
思路:先排序,再删除重复元素,然后就是索引元素离散化后对应的值。
假定待离散化的序列为a[n],b[n]是序列a[n]的一个副本,则对应以上三步为:
sort(sub_a,sub_a+n);
int size=unique(sub_a,sub_a+n)-sub_a;//size为离散化后元素个数
for(i=0;i<n;i++)
a[i]=lower...
分类:
其他好文 时间:
2015-05-11 10:49:40
阅读次数:
127
--string.len(s)--返回字符串s的长度--string.rep(s, n)--返回重复n次字符串s的串,你使用string.rep("a", 2^20)可以创建一个1M bytes的字符串(比如,为了测试需要)--string.lower(s)--将s中的大写字母转换成小写(strin...
分类:
其他好文 时间:
2015-05-08 19:58:26
阅读次数:
134
Given a string s consists of upper/lower-case alphabets and empty space characters '
', return the length of last word in the string.
If the last word does not exist, return 0.
Note: A word is...
分类:
其他好文 时间:
2015-05-06 23:05:47
阅读次数:
196
数据库和表名在 Windows 中是大小写不敏感的 ,而在大多数类型的 Unix 系统中是大小写敏感的Windows 版的 MySQL 默认继承 os 的大小写习惯,即使 SQL中有区分,在导入的时候都会被转为小写,如果今后再将此数据库导出就可能存在大小写的问题。my.ini 中有属性lower_c...
分类:
数据库 时间:
2015-05-06 06:53:11
阅读次数:
138