![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
字符串
谛听-
线上幽灵
展开
-
输出两个字符串数字的差
已知:第一个数字大于第二个数字。#include <iostream>#include <vector>using namespace std;// 1004// 45// 959// 114// 45// 69string subtract(string a, string b) { if (a == "") { return ""; } if (b == "") { return原创 2021-01-19 22:39:07 · 464 阅读 · 1 评论 -
leetcode---longest-substring-without-repeating-characters---字符串
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for “abcabcbb” is “abc”, which the length is 3. For “原创 2017-11-05 18:36:26 · 175 阅读 · 0 评论 -
leetcode---longest-palindromic-substring---字符串
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.class Solution {public:原创 2017-11-05 19:40:45 · 223 阅读 · 0 评论 -
leetcode---wildcard-matching---字符串,dp
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 the en原创 2017-11-21 18:22:24 · 276 阅读 · 0 评论 -
leetcode---roman-to-integer---字符串
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.class Solution {public: int romanToInt(string s) { int n = s.length();原创 2017-11-30 23:46:39 · 209 阅读 · 0 评论 -
leetcode---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.class Solution {public: string multiply原创 2017-11-22 19:20:24 · 207 阅读 · 0 评论 -
leetcode---implement-strstr---字符串
Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.class Solution {public: void makeNext(char *p, int *next) {原创 2017-11-23 20:11:55 · 216 阅读 · 0 评论 -
leetcode---zigzag-conversion---字符串
class Solution {public: string convert(string s, int nRows) { if(nRows <= 1) return s; int n = s.length(); string ans = ""; int i, j; if(nRow原创 2017-12-16 22:14:59 · 190 阅读 · 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 cas...原创 2018-02-19 19:20:00 · 215 阅读 · 0 评论 -
leetcode---regular-expression-matching---字符串
Implement regular expression matching with support for’.’and’*’. ‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element.The matching should cover the entire input str...原创 2017-11-20 19:56:59 · 219 阅读 · 0 评论 -
leetcode--substring-with-concatenation-of-all-words---字符串
You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without an...原创 2018-03-02 17:56:58 · 201 阅读 · 0 评论 -
leetcode---add-binary---字符串
Given two binary strings, return their sum (also a binary string). For example, a =”11” b =”1” Return”100”.class Solution {public: int atoi(char c) { return c - '0'; } string原创 2017-11-14 18:30:49 · 188 阅读 · 0 评论 -
leetcode---anagrams---字符串
Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case.class Solution {public: vector<string> anagrams(vector<string> &strs) {原创 2017-11-14 18:11:24 · 201 阅读 · 0 评论 -
竖式问题
找出所有形如abc*de的算式,使得在完整的竖式中,所有数字都属于一个特定的数字集合。#include "iostream"#include "vector"#include "string.h"#include "set"#include "ctype.h"#include "stdio.h"using namespace std;int main(){ char s[10原创 2016-04-05 10:38:21 · 633 阅读 · 0 评论 -
leetcode---Add Binary---string
Given two binary strings, return their sum (also a binary string).For example, a = “11” b = “1” Return “100”.class Solution {public: string addBinary(string a, string b) { int len1 = a.原创 2016-04-08 21:37:34 · 334 阅读 · 0 评论 -
leetcode---Reverse String
Write a function that takes a string as input and returns the string reversed.Example: Given s = “hello”, return “olleh”.class Solution {public: string reverseString(string s) { reverse(s原创 2016-05-12 12:45:11 · 290 阅读 · 0 评论 -
KMP
输入 第一行一个整数N,表示测试数据组数。接下来的N*2行,每两行表示一个测试数据。在每一个测试数据中,第一行为模式串,由不超过10^4个大写字母组成,第二行为原串,由不超过10^6个大写字母组成。其中N<=20输出 对于每一个测试数据,按照它们在输入中出现的顺序输出一行Ans,表示模式串在原串中出现的次数。#include "iostream"#include "algorithm"#in原创 2016-04-22 16:27:34 · 330 阅读 · 0 评论 -
STL---string用法
#include "iostream"#include "vector"#include "string"#include "sstream"using namespace std;int main(){ string s = "aabcdef.txt"; cout << endl << "--------------------------find, rfind-------原创 2016-08-27 15:52:47 · 569 阅读 · 0 评论 -
leetcode--- Bulls and Cows---字符串
You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that原创 2017-03-02 14:33:25 · 249 阅读 · 0 评论 -
leetcode---Add Strings
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.Note:The length of both num1 and num2 is < 5100. Both num1 and num2 contains only digits 0-9. Both原创 2017-04-14 08:44:49 · 640 阅读 · 0 评论 -
leetcode---Fizz Buzz
Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For n原创 2017-04-26 21:33:10 · 370 阅读 · 0 评论 -
leetcode---count-and-say---字符串
The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, … 1is read off as”one 1”or11. 11is read off as”two 1s”or21. 21is read off as”one 2, thenone 1”o原创 2017-11-06 19:14:58 · 208 阅读 · 0 评论 -
leetcode---length-of-last-word---字符串
Given a string s consists of upper/lower-case alphabets and empty space characters’ ‘, return the length of last word in the string. If the last word does not exist, return 0. Note: A word is defined原创 2017-11-14 18:10:30 · 182 阅读 · 0 评论 -
最长回文子串
输入一个字符串,求出其中最长的回文串。子串的含义是:在原串中连续出现的字符串片段。在判断时,应该忽略所有标点符号和空格,且忽略大小写,但输出保持原样。输入字符串长度不超过5000,且单独占据一行。应该输出最长的回文串,如果有多个,输出起始位置最靠左的。#include "iostream"#include "vector"#include "string.h"#include "set"#i原创 2016-04-05 10:00:23 · 373 阅读 · 0 评论