Write a function to find the longest common prefix string amongst an array of strings. 大意就是,写一个函数可以找到一个数组字符串中的最长前缀。 分析: 最长前缀的最大值为数组字符串中长度最短的字符,由最短字符串由 ...
分类:
其他好文 时间:
2016-08-10 20:49:33
阅读次数:
142
字符串分割经常用到,这里做一个记录。方便查阅。1.使用strtok();其中采用strtok(),分隔符可以是多种,如*,#中的一种或几种的组合vector<string>stringSplit(strings,constchar*split)
{
vector<string>result;
constintsLen=s.length();
char*cs=newchar[sLen..
分类:
编程语言 时间:
2016-08-10 14:38:27
阅读次数:
191
344.ReverseStringWriteafunctionthattakesastringasinputandreturnsthestringreversed.Example:Givens="hello",return"olleh".思路1:使用一个新的string来存放结果。classSolution{
public:
stringreverseString(strings){
intlen=s.size();
stringresult;
for(intn=0;n<l..
分类:
其他好文 时间:
2016-08-10 14:32:15
阅读次数:
179
6.ZigZagConversion题目:https://leetcode.com/problems/zigzag-conversion/stringconvert2(strings,intnumRows){
if(s.length()<2||numRows<2)
returns;
intcycle=2*numRows-2;
stringtmp;
stringresult;
for(inti=0;i<numRows;i++)
{
if(i==0||i==numRow..
分类:
Web程序 时间:
2016-08-09 00:48:51
阅读次数:
196
AppiumDriver getAppStrings() 默认系统语言对应的Strings.xml文件内的数据。iOS driver.getAppStrings(Stringlanguage) 查找某一个语言环境对应的字符串文件Strings.xml内数据 sendKeyEvent(intkey) ...
分类:
移动开发 时间:
2016-08-08 14:29:39
阅读次数:
474
Given two strings S and T, determine if they are both one edit distance apart. 分析:https://segmentfault.com/a/1190000003906621 虽然我们可以用Edit Distance的解法, ...
分类:
其他好文 时间:
2016-08-06 14:15:16
阅读次数:
137
题目
Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstr...
分类:
编程语言 时间:
2016-08-06 00:39:10
阅读次数:
279
Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we thin ...
分类:
其他好文 时间:
2016-08-06 00:18:31
阅读次数:
139
题意: Write a function to find the longest common prefix string amongst an array of strings. (Easy) 这两天实验室项目太忙了, 老板各种活,只能挑着先水几道easy题,这两个题是昨天做的没来得及写总结。 分 ...
分类:
其他好文 时间:
2016-08-05 23:05:21
阅读次数:
179
Question:
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
按位求和
Algorithm:
从后往前加,有三种情况,具体见程序
Accepted Code:
class So...
分类:
其他好文 时间:
2016-08-04 10:35:29
阅读次数:
118