如题

思路:暴力就行了。1ms的暴力!!!别的牛人写出来的,我学而抄之~

 int strStr(char* haystack, char* needle) {
if (!haystack || !needle) return -;
for (int i = ; ; ++i) {
for (int j = ; ; ++j) {
if (needle[j] == ) return i;
if (haystack[i + j] == ) return -;
if (haystack[i + j] != needle[j]) break;
}
}
}

strStr()

LeetCode Implement strStr() 实现strstr()的更多相关文章

  1. 乘风破浪:LeetCode真题_028_Implement strStr()

    乘风破浪:LeetCode真题_028_Implement strStr() 一.前言     这次是字符串匹配问题,找到最开始匹配的位置,并返回. 二.Implement strStr() 2.1 ...

  2. leetcode5 Implement strstr() 实现strstr函数功能

    Implement strstr() 实现strstr函数功能 whowhoha@outlook.com Question: Implement strstr(). Returns the index ...

  3. 每日一道 LeetCode (9):实现 strStr()

    每天 3 分钟,走上算法的逆袭之路. 前文合集 每日一道 LeetCode 前文合集 代码仓库 GitHub: https://github.com/meteor1993/LeetCode Gitee ...

  4. [LeetCode] Implement strStr() 实现strStr()函数

    Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle ...

  5. [Leetcode] implement strStr() (C++)

    Github leetcode 我的解题仓库   https://github.com/interviewcoder/leetcode 题目: Implement strStr(). Returns ...

  6. LeetCode Implement strStr()(Sunday算法)

    LeetCode解题之Implement strStr() 原题 实现字符串子串匹配函数strStr(). 假设字符串A是字符串B的子串.则返回A在B中首次出现的地址.否则返回-1. 注意点: - 空 ...

  7. [LeetCode] 28. Implement strStr() 实现strStr()函数

    Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle ...

  8. [LeetCode] Implement strStr()

    Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if need ...

  9. [leetcode]28. Implement strStr()实现strStr()

    Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle ...

  10. LeetCode: Implement strStr() [027]

    [题目] Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if ...

随机推荐

  1. LeetCode: 171 Excel Sheet Column Number(easy)

    题目: Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, r ...

  2. Net Core 下载图片

    直接上代码 string url = https://www.cnblogs.com/images/logo_small.gif; //获取网站当前根目录 string sWebRootFolder ...

  3. UML——初识

    初识 刚刚接触到UML的时候,先看的书,对整本书的内容做了宏观的把控.感觉UML这个东西和自己想象中的不一样.起初我认为它只是一个工具,将软件开发过程中不同的阶段用不用种类的图表现出来,后来才发现它是 ...

  4. cogs 2620. [HEOI2012]朋友圈

    /*70分 被卡T*/ #include<iostream> #include<cstdio> #include<cstring> using namespace ...

  5. 清北刷题冲刺 10-30 p.m

    少女 #include<iostream> #include<cstdio> #include<queue> #include<cstdlib> #de ...

  6. sys_guid()

    create extension "uuid-ossp"; create or replace function sys_guid() returns uuid as $$sele ...

  7. HDU1729 Stone Game

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1729 思路:理解错题目了,以为SG模板直接套就行了.后来队友说了那个ci是不断变化的.那么每次可以放的石头 ...

  8. java中静态代码块的用法 static用法详解和static静态导入

    (一)java 静态代码块 静态方法区别一般情况下,如果有些代码必须在项目启动的时候就执行的时候,需要使用静态代码块,这种代码是主动执行的;需要在项目启动的时候就初始化,在不创建对象的情况下,其他程序 ...

  9. mathjax;latex

    \lfloor $\lfloor$ \rfloor $\rfloor$ \sum_{i=1}^{n} $\sum_{i=1}^{n}$ \mu $\mu$ \mid $\mid$ \Leftright ...

  10. CompareToBuilder构建Comparator

    import org.apache.commons.lang.builder.CompareToBuilder; Collections.sort(outboundNotices, new Compa ...