简体   繁体   English

识别哪个是子字符串/哪个不是或子序列/序列

[英]identify which is a substring/which is not or sub-sequences/sequence

I'm simplifying a lot but I have a load of strings that are sequences like: 我简化了很多,但是我有很多类似以下内容的字符串:

`"A-B-C-D-E"`, "A-B-C", "A-B", "B-C", "D-E"

but could just as easily be lists of letters. 但也可以很容易地是字母列表。

They are all from a limited number of letters, and one of the sequence contains all the others. 它们全部来自有限数量的字母,并且序列之一包含所有其他字母。 My question is for a set of these sequences how to determine which is the one that contains all the others/identify the substrings versus the complete sequence/flatten into one to end up with just: 我的问题是针对这些序列中的一组,如何确定哪一个包含所有其他序列/识别子字符串与完整序列/展平成一个序列最终以:

"A-B-C-D-E"

In python 在python中

This is what you have to do as Cyber and Muradin said: I am mostly a java guy, so I will give you a code-like algorithm to perform your task. 正如Cyber​​和Muradin所说的,这是您要做的:我主要是一个Java专家,所以我将为您提供类似代码的算法来执行您的任务。 Here it is: 这里是:

If lengthOfString(String string) == 9 check each of the characters of the string to see if they are unique if there is only one combination of the letters, then check the positions of the letters, and compare them with what you expect it to be else, if there are several combinations of the letters, then check each position and compare it with the letter you would expect. 如果lengthOfString(String string)== 9,则检查字符串中的每个字符(如果只有一个字母组合)是否唯一,然后检查字母的位置,并将其与期望的位置进行比较否则,如果字母有几种组合,则检查每个位置并将其与您期望的字母进行比较。

Hope that solves your problem

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM