博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
leetcode[30]Substring with Concatenation of All Words
阅读量:4679 次
发布时间:2019-06-09

本文共 819 字,大约阅读时间需要 2 分钟。

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 any intervening characters.

For example, given:

S: "barfoothefoobarman"
L: ["foo", "bar"]

You should return the indices: [0,9].

(order does not matter).

class Solution {public:    vector
findSubstring(string S, vector
&L) { vector
res; int len=L[0].size()*L.size(); if (S.empty()||L.empty()||S.size()
Lmap; map
temp; for (int i=0;i
Lmap[word]) break; } if (j==i+len) res.push_back(i); } return res; }};

 

转载于:https://www.cnblogs.com/Vae1990Silence/p/4283617.html

你可能感兴趣的文章
S2JDBC テーブルを利用した独自仕様のid採番メソッド
查看>>
P3698 [CQOI2017]小Q的棋盘
查看>>
动态规划入门 洛谷P2409 Y的积木
查看>>
【第一季】CH04_FPGA设计Verilog基础(一)Enter a post title
查看>>
算法的基本概念
查看>>
2018-2019-1 20189206 《Linux内核原理与分析》第八周作业
查看>>
股票买卖问题
查看>>
Matlab+ModelSim“傻瓜化”设计数字滤波器
查看>>
直接数字频率合成器(DDS)基本原理
查看>>
转载:【小作品】STM32无线WIFI视频小车制作剖析(上)
查看>>
echarts学习网站
查看>>
原生的js轮播图
查看>>
字符串操作、文件操作,英文词频统计预处理
查看>>
telnet不能用!!!提示:-bash: telnet: command not found
查看>>
HTTP劫持和DNS劫持
查看>>
堆排序
查看>>
Planning for a period of time
查看>>
隐式转换的一点想法
查看>>
web框架前言与学生数据库系统(附1.0源码)
查看>>
JavaScript基础
查看>>