当前位置:网站首页>Openjudge: find all substring positions
Openjudge: find all substring positions
2022-07-28 05:36:00 【Programmer system】
describe
Enter two strings s1,s2, find s2 stay s1 All the places that appear in
The appearance of two substrings cannot overlap . for example 'aa' stay aaaa The only place in the 0,2
Input
The first line is an integer n
Next there is n That's ok , Two strings without spaces on each line s1,s2
Output
For each line , From small to large output s2 stay s1 All the positions in . Location slave 0 Start counting
If s2 It didn't show up , Output "no"
It doesn't matter to output more spaces at the end of the line
The sample input
4 ababcdefgabdefab ab aaaaaaaaa a aaaaaaaaa aaa 112123323 a
Sample output
0 2 9 14 0 1 2 3 4 5 6 7 8 0 3 6 no
Code
n = int(input())
for i in range(n):
s = input().split()
m = 0
if s[1] not in s[0]:
print('no', end='')
for j in s[0]:
a = s[0].find(s[1],m)
if a == -1:
continue
else:
m = a + len(s[1])
print(a,'',end='')
print("") # Each loop wrap 边栏推荐
- First acquaintance with C language (2)
- Scope, execution process and life cycle of bean
- Framework step by step easy-to-use process
- lamda 获取当前循环数,AtomicInteger
- You must configure either the server or JDBC driver (via the ‘serverTimezone)
- First acquaintance with C language (1)
- BeanUtils. Copyproperties cannot copy different list sets problem solving lists.transform function
- Edge calculation kubeedge+edgemash
- 深度学习热力图可视化的方式
- ByteBuffer. Position throws exception illegalargumentexception
猜你喜欢

多线程进阶:synchronized底层原理,锁优化、锁升级的过程

How about ink cloud?

论文模型主图范例

Personal summary of restful interface use

集合框架的操作使用

Operation and use of collection framework

Redis' bloom filter

测试开发---自动化测试中的UI测试

After ruoyi generates the code corresponding to the database, what should I do to make the following image look like

多模块打包:程序包:xxx不存在
随机推荐
Scanf function of input and output function in C language
VMware Workstation 与 Device/Credential Guard 不兼容。禁用 Device/Credential Guard
JVM篇 笔记4:内存模型
mysql中使用list作为参数进行查询
Thinking on multi system architecture design
restFul接口使用个人总结
How about ink cloud?
Image enhancement - msrcr
openjudge:判断字符串是否为回文
repackag failed: Unable to find main class
openjudge:万年历
Distillation model diagram
凛冬已至,程序员该怎么取暖
First acquaintance with C language (1)
There is no crossover in the time period within 24 hours
Non functional test
JVM notes 3: class loading and bytecode Technology
Redis 之布隆过滤器
Digital twin solutions inject new momentum into the construction of chemical parks
lamda 获取当前循环数,AtomicInteger