In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
We talked about the specific implementation of the KMP algorithm in the last blog, so we will look at the application of the KMP algorithm in this section. Question: how do I find out if a specified substring exists in the target string?
Let's take a look at the new features in the string class, as shown in the following figure
1. Substring lookup (direct application of KMP algorithm)
Int indexOf (const char* s) const
Int indexOf (const String& s) const
Let's look at the implementation of the specific source code, as follows
Int String::indexOf (const char* s) const {return kmp (m_str, s? S: "");} int String::indexOf (const String& s) const {return kmp (m_str, s.m_str);}
We can directly use the kmp function implemented by our blog in the previous section to implement the indexOf function. Let's take a look at the effect.
# include # include # include "DTString.h" using namespace std;using namespace DTLib;int main () {String s = "ababax"; cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.