字符串
crazy__chen
只要有一个人爱我,懂我,愿意等我,我便勇往直前,无所不能。
展开
-
leetcode--Wildcard Matching
Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover t原创 2015-08-08 16:43:41 · 976 阅读 · 0 评论 -
剑指offer--翻转单词顺序列
题目描述JOBDU最近来了一个新员工Fish,每天早晨总是会拿着一本英文杂志,写些句子在本子上。同事Cat对Fish写的内容颇感兴趣,有一天他向Fish借来翻看,但却读不懂它的意思。例如,“student. a am I”。后来才意识到,这家伙原来把句子单词的顺序翻转了,正确的句子应该是“I am a student.”。Cat对一一的翻转这些单词顺序可不在行,你能帮助他么?分原创 2015-09-21 13:18:51 · 1134 阅读 · 0 评论 -
剑指offer--左旋转字符串
题目描述汇编语言中有一种移位指令叫做循环左移(ROL),现在有个简单的任务,就是用字符串模拟这个指令的运算结果。对于一个给定的字符序列S,请你把其循环左移K位后的序列输出。例如,字符序列S=”abcXYZdef”,要求输出循环左移3位后的结果,即“XYZdefabc”。是不是很简单?OK,搞定它!public class Solution { public String L原创 2015-04-13 01:03:50 · 1112 阅读 · 0 评论 -
剑指offer--把字符串转换成整数
题目描述将一个字符串转换成一个整数,要求不能使用字符串转换整数的库函数。如果是非法的整数字符,比如1aa3,则返回0。public int StrToInt(String str) { char[] chars = str.toCharArray(); long sum = 0; int max = 0x7FFFFFFF; int min = 0x80000000;原创 2015-04-17 13:19:39 · 1208 阅读 · 0 评论 -
剑指offer--第一个只出现一次的字符
题目描述在一个字符串(1public class Solution { public int FirstNotRepeatingChar(String str) { if(str.length()==0) return -1; int arr[] = new int[26]; int mark = -1;原创 2015-04-12 16:59:52 · 967 阅读 · 0 评论 -
剑指offer--字符串的排列
题目描述输入一个字符串,按字典序打印出该字符串中字符的所有排列。例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。输入描述:输入一个字符串,长度不超过9(可能有字符重复),字符只包括大小写字母。按字典序打印出该字符串中字符的所有排列。public ArrayList Permutation(String str)原创 2015-04-18 19:34:04 · 1418 阅读 · 0 评论 -
剑指offer--替换空格
题目描述请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。public class Solution { public String replaceSpace(StringBuffer str) { int spaceCount = 0; for(int i=0;i原创 2015-04-10 22:12:54 · 1071 阅读 · 1 评论 -
最长公共子序列&最长公共子串
最长公共子序列 & 最长公共子串的区别:找两个字符串的最长公共子串,这个子串要求在原字符串中是连续的。而最长公共子序列则并不要求连续。最长公共子序列的问题参考:最长公共子序列。String solve(String str1,String str2){ StringBuilder sb = new StringBuilder(); if (str1 == null || str1.原创 2015-05-01 23:09:29 · 1062 阅读 · 0 评论 -
leetcode--Word Ladder II
Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:Only one letter can be changed at a timeEach intermediate word must exi原创 2015-08-07 12:36:46 · 1296 阅读 · 0 评论 -
leetcode--Word Ladder
Given two words (beginWord and endWord), and a dictionary, find the length of shortest transformation sequence from beginWord to endWord, such that:Only one letter can be changed at a timeEach int原创 2015-08-07 10:50:28 · 1196 阅读 · 0 评论 -
leetcode--Scramble String
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great / \ gr原创 2015-08-09 16:31:29 · 1311 阅读 · 0 评论 -
剑指offer--正则表达式匹配
题目描述请实现一个函数用来匹配包括'.'和'*'的正则表达式。模式中的字符'.'表示任意一个字符,而'*'表示它前面的字符可以出现任意次(包含0次)。 在本题中,匹配是指字符串的所有字符匹配整个模式。例如,字符串"aaa"与模式"a.a"和"ab*ac*a"匹配,但是与"aa.a"和"ab*a"均不匹配分类:字符串解法1:每次从字符串里拿出一个字符和模式中的字符原创 2015-09-21 23:14:59 · 1284 阅读 · 0 评论