字符串 (string)
文章平均质量分 76
beiyetengqing
http://blog.csdn.net/beiyeqingteng 的镜像站
展开
-
Interleaving strings
Given two strings, print all the interleavings of the two strings. Interleaving means that the if B comes after A .It should also come after A in the interleaved string.Example: Input: AB and CD转载 2013-01-26 01:44:19 · 541 阅读 · 0 评论 -
Longest Valid Parentheses
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()",原创 2013-01-12 02:32:31 · 635 阅读 · 0 评论 -
evaluate a mathematical expression
Question:You are give a piece of mathematical expression, e.g., 3 * 4 + 5, return the value of that expression.public class EvaluateDeluxe { // result of applying binary operator op to two op原创 2013-02-07 13:53:45 · 896 阅读 · 0 评论 -
把手机键盘输入转化成短消息
手机键盘每个数字对应的字符如下:0 ---> "0";1 ---> "1";2 --- > "ABC2";3 ---> "DEF3";4 ---> "GHI4";5 ---> "JKL5";6 ---> "MNO6";7 ---> "PQRS7";8 ---> "TUV8";9 ---> "WXYZ9";* ---> 空格;# ---> 断开;原创 2013-02-11 03:51:58 · 748 阅读 · 0 评论 -
Leetcode: String to Integer (atoi)
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input原创 2013-01-02 12:52:36 · 2906 阅读 · 0 评论 -
把一个字符串转成double类型的数
问题:给一个字符串,比如“-12.05”,把它转成相应的double类型的数。分析:在进行转换的时候,要注意以下问题:1. 该字符串是否为空2. 是否该字符串含有符号;3. 该字符串内是否有非法字符;4. 小数点的位置;备注:本文不考虑溢出的情况。代码如下:/* * allowed format: -.4; +.4; -1.2; 2.5;35.;+35.原创 2013-02-18 01:40:38 · 10358 阅读 · 1 评论 -
输出个数最多的连续的字符
问题:给定一个字符串,输出个数最多的连续的字符(不含空格)。比如:"this is a sentence" => [t, h, i, s, i, s, a, s, e, n, t, e, n, c, e]"thiis iss a senntencee" => [i, s, n, e]"thiisss iss a senntttenceee" => [s, t, e]"t原创 2013-04-22 13:01:32 · 1131 阅读 · 0 评论 -
determine S is a subsequence of T
Question:You're given a large string T, and a stream of smaller string S1, S2, S3 ... Determine whether Si is a subsequence of T. |T| |Si| alphabet is 'a' - 'z'Example:T = abcdefgS1 =原创 2013-10-10 11:37:56 · 1089 阅读 · 0 评论 -
string rotation
Write a function that takes two input strings and determines if one is a rotation of the other. For instance, “ProgrammingPraxis” and “PraxisProgramming” are rotations of each other, but “Programmin转载 2013-01-08 13:44:37 · 846 阅读 · 0 评论 -
Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be n原创 2013-01-23 07:53:58 · 781 阅读 · 0 评论 -
版本号比较
问题:给定两个版本号,比较哪一个版本号更新。比如 1.2.9 比 1.2.4 新。 1.0.1 比 1.0 新。 思路:当比较版本号时,我们需要从头到尾比较每一组数据。所以,我们需要首先得到版本号的一个数字,第二个数字,第三个数字,然后和另一个版本号码所对应的数字进行比较。代码:public class VersionComparison { public static vo原创 2012-10-23 11:10:02 · 1361 阅读 · 1 评论 -
Java实现最长公共子序列
最长公共子序列(LCS)定义:一个数列 S,如果分别是两个或多个已知数列的子序列,且是所有符合此条件序列中最长的,则 S 称为已知序列的最长公共子序列。比如数列A = “abcdef”, B = “adefcb”. 那么两个数列的公共子序列是"adef". 最长公共子序列和最长公共子字符串是有区别的,公共子序列里的元素可以不相邻,但是公共子字符串必须是连接在一起的。比如A和B的公共子字符串原创 2012-12-03 11:48:21 · 1230 阅读 · 0 评论 -
Anagrams
Question:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.Analysis:In order to determine whether two words are anagrams or not原创 2012-12-07 03:16:01 · 1338 阅读 · 0 评论 -
Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total nu原创 2012-12-16 13:12:15 · 1281 阅读 · 0 评论 -
Multiply Strings
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.public class Solution { public static原创 2012-12-29 14:19:31 · 2029 阅读 · 0 评论 -
ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I原创 2013-01-01 14:39:04 · 3817 阅读 · 0 评论 -
Valid Number
Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be amb原创 2013-01-02 12:00:43 · 2187 阅读 · 0 评论 -
Remove Duplicate Letters
Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical order a原创 2016-02-02 01:00:46 · 1664 阅读 · 0 评论