Write a function to find the longest common prefix string amongst an array of strings. 写一个函数找到最长的公共前缀在所有的字符串数组中。 例如 "aba" "abbb" "abcc" "ab" 它们的公共前缀就是 ...
分类:
其他好文 时间:
2017-06-29 09:58:59
阅读次数:
113
字面量: 字符串:单引号或双引号扩起来; %@:系统自动添加,数字则自动去除@(); 无单双引号,系统做数字处理。 Single or double quoting variables (or substitution variable strings) cause %@, %K, or $vari ...
分类:
其他好文 时间:
2017-06-28 20:30:29
阅读次数:
227
众所周知,在Python中如果访问字典中不存在的键,会引发KeyError异常(JavaScript中如果对象中不存在某个属性,则返回undefined)。但是有时候,字典中的每个键都存在默认值是非常方便的。例如下面的例子: 该例子统计strings中某个单词出现的次数,并在counts字典中作记录 ...
分类:
编程语言 时间:
2017-06-28 17:14:52
阅读次数:
263
typeScript 是一种给 JavaScript 添加特性的语言扩展。如:类型批注和编译时类型检查、类、接口、模块。 数据类型系统: numbers, strings, structures, boolean等,当类型没有给出时,TypeScript 编译器利用类型推断以推断类型。如果由于缺乏声 ...
分类:
其他好文 时间:
2017-06-28 14:18:00
阅读次数:
192
Given two binary strings, return their sum (also a binary string). For example,a ="11"b ="1"Return"100". 题意:将两个以字符串形式保存的二进制数进行相加。 思路:其实不管是以数组、字符串形式,加或 ...
分类:
其他好文 时间:
2017-06-27 18:38:39
阅读次数:
137
一、题目 1、描述 2、题意 将两个字符串表示的数字进行乘法计算,其中,若直接转换成整数计算会溢出。 二、解答 1、思路: ① 在 num2 中从后向前取出一个数字依次乘以num1,再进行相加 ② 若 num2中逆数第二个数乘的结果后边需要加一个 0,第三个逆数则要加两个 0.... ③ 可以直接用 ...
分类:
其他好文 时间:
2017-06-27 12:59:42
阅读次数:
187
Description Let x and y be two strings over some finite alphabet A. We would like to transform x into y allowing only operations given below: Deletion ...
分类:
其他好文 时间:
2017-06-26 13:43:07
阅读次数:
226
Power Strings Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 39658 Accepted: 16530 Description Given two strings a and b we define a*b to ...
分类:
其他好文 时间:
2017-06-26 12:46:36
阅读次数:
188
Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. 题意:anagrams的意思是回文构词法。回文构词法有一个特点:单词里 ...
分类:
其他好文 时间:
2017-06-25 22:08:19
阅读次数:
148
一、strings和strconv的使用 strings strings.HasPrefix(s string,preffix string) bool:判断字符串s是否以prefix开头 stirngs.HasSuffix(s string,suffix string) bool:判断字符串s是否 ...
分类:
其他好文 时间:
2017-06-24 10:09:07
阅读次数:
176