整理自统计之都论坛
方法一 使用strsplit函数
a <- "aggcacggaaaaacgggaataacggaggaggacttggcacggcattacacggagg"
b <- strsplit(as.character(a),"ag")
length(b[[1]]) - 1 ##子字符串"ag"的出现个数
方法二 使用正则式函数
a <- "aggcacgg...
分类:
其他好文 时间:
2014-07-22 23:02:52
阅读次数:
288
[ 问题: ]
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.
[...
分类:
其他好文 时间:
2014-07-22 23:01:35
阅读次数:
331
29:数组中出现次数超过一半的数字 方法a. 排序取中 O(nlogn) 方法b.
partition 函数分割找中位数 >=O(n) 方法 c. 设计数变量,扫描一遍。 O(n)#include int findNumber(int
data[], unsigned length){/* if(c...
分类:
其他好文 时间:
2014-05-02 19:47:41
阅读次数:
535
许多次通过,主要是没有考虑到这种情况:“A C ”结尾有多重空格的情况。 1 public class
Solution { 2 public int lengthOfLastWord(String s) { 3 int j, k; 4 if(s == nu...
分类:
其他好文 时间:
2014-05-02 08:21:00
阅读次数:
300
最近在看Jdk6中String的源码的时候发现String的有个这样的构造方法,源代码内容如下:
public String(String original) {
int size = original.count;
char[] originalValue = original.value;
char[] v;
if (originalValue.length > size) {
...
分类:
其他好文 时间:
2014-05-02 06:34:52
阅读次数:
237
1 //桶排序思想 2 //假如要排序的是数字是 2 4 5 5 5 8 8 9 1 1 3
#include 4 #define length 10 5 int main() 6 { 7 //数组元素值全部初始化为0 8 int
array[length]={0}; 9 ...
分类:
其他好文 时间:
2014-05-01 22:19:46
阅读次数:
342
题目: Given a string S, find the longest palindromic
substring in S. You may assume that the maximum length of S is 1000, and there
exists one unique lo...
分类:
其他好文 时间:
2014-05-01 20:07:13
阅读次数:
429
/**js Unicode编码转换*/vardecToHex =function(str)
{varres=[];for(vari=0;i < str.length;i++)
res[i]=("00"+str.charCodeAt(i).toString(16)).slice(-4);return"...
分类:
Web程序 时间:
2014-05-01 19:36:51
阅读次数:
427
冒泡排序
思路:就是每次将最大或最小的元素放到数组的最后,so easy!时间复杂度为(O(n^2))
public class BubbleSort {
public static void bubbleSort(int[] a) {
for (int j = 1; j < a.length; j++) {
for (int i = 0; i < a.length - j; i+...
分类:
编程语言 时间:
2014-04-30 22:12:40
阅读次数:
309
使用函数操作链表
1:计算链表中结点的个数:定义一个Length_list()函数用于计算链表中结点的个数
函数代码:
//计算链表中结点的个数
void Length_list(PNODE pHead)
{
PNODE p = pHead->pNext;
int len = 0;
while(NULL != p)
{
len++;
p = p->pNext;
...
分类:
其他好文 时间:
2014-04-29 13:28:21
阅读次数:
302