首页 > 其他 > 详细

Leetcode-5013 Index Pairs of a String(字符串的索引对)

时间:2019-06-02 11:18:07      阅读:131      评论:0      收藏:0      [点我收藏+]

依旧没啥好说的

 1 #define _for(i,a,b) for(int i = (a);i < b;i ++)
 2 
 3 class Solution
 4 {
 5     public:
 6         vector<vector<int>> indexPairs(string text, vector<string>& words)
 7         {
 8             set<string> s;
 9             vector<vector<int>> v;
10             _for(i,0,words.size())
11                 s.insert(words[i]);
12             
13             _for(i,0,text.size())
14                 _for(j,i,text.size())
15                 {
16                     string s1;
17                     _for(k,i,j+1)
18                         s1 += text[k];
19                     
20                     if(s.count(s1))
21                     {
22                         vector<int> tmp;
23                         tmp.push_back(i);
24                         tmp.push_back(j);
25                         v.push_back(tmp);
26                     }
27                 }
28             return v;
29         }
30 };

 

Leetcode-5013 Index Pairs of a String(字符串的索引对)

原文:https://www.cnblogs.com/Asurudo/p/10961896.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!