Go语言中字符串的拼装方法很多,那么问题来了,到底哪家性能好?下面代码,分别比较了 fmt.Sprintf,string +,strings.Join,bytes.Buffer,方法是循环若干次比较总时间。在VMWare下的Ubuntu 14.04下运行的结果表明:fmt.Sprintf 和 str...
分类:
编程语言 时间:
2015-03-07 13:59:12
阅读次数:
138
s3 Strings and o console utput1Python里面还有一种好的数据类型是String2 一个String是通过'' 或者 ""包成的串3Python是通过\来实现转义字符的4我们可以使用""来避免转义字符的出现 练习: 把变量letter设置为MONTY的第五个字符5 ....
分类:
编程语言 时间:
2015-03-07 06:11:19
阅读次数:
218
Given two strings S1 and S2, S = S1 - S2 is defined to be the remaining string after taking all the characters in S2 from
S1. Your task is simply to calculate S1 - S2 for any given strings. However,...
分类:
其他好文 时间:
2015-03-06 11:21:17
阅读次数:
140
Given two numbers represented as strings, return multiplication of the numbers as a string.
Note: The numbers can be arbitrarily large and are non-negative.
题意:字符串的乘法。
思路:模拟竖乘的思路,跟大数计算一样,先将字符串倒置
...
分类:
其他好文 时间:
2015-03-06 01:06:45
阅读次数:
139
二叉树二叉树的抽象数据类型的接口定义publicinterfaceBinaryTree
{
finalString[]mode={"preOrder","inOrder","postOrder","levelOrder"};
booleancreateBTree(Stringgt);
booleanisEmpty();
voidtraverseBTree(Strings);
ObjectfindBTree(Objectobj);
intdepthBTree();..
分类:
其他好文 时间:
2015-03-04 19:29:46
阅读次数:
134
Write a function to find the longest common prefix string amongst an array of strings.
这个题目非常简单,只要弄清楚题意就可以非常快地解决,我的C++代码实现如下: string longestCommonPrefix(vector &strs) {
if (strs.empt...
分类:
其他好文 时间:
2015-03-04 19:13:18
阅读次数:
127
“strcmp()” Anyone?
strcmp() is a library function in C/C++ which compares two strings. It takes two strings as input parameter and decides which one is lexicographically larger or smaller: If t...
分类:
其他好文 时间:
2015-03-04 19:08:41
阅读次数:
182
Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.http://www.cnblogs.com/easonliu/p/364...
分类:
其他好文 时间:
2015-03-04 15:56:43
阅读次数:
131
题目链接:Anagrams
Given an array of strings, return all groups of strings that are anagrams.
Note: All inputs will be in lower-case.
这道题的要求是给定字符串数组,返回能构成异构的所有字符串。
anagram,即异构,意思是指由颠倒字母顺序组成的单词,比如“live”...
分类:
其他好文 时间:
2015-03-04 11:08:57
阅读次数:
144
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-03-04 09:44:51
阅读次数:
122