Questions tagged [longest-substring]

Longest Substring is a classic computer science problem: given two strings, find the common strings, then return the string(s) in common with the greatest length.

The longest common substring problem is a derivative of the edit distance problem, which focuses on the most common typing errors:

  • namely character omissions
  • insertions
  • substitutions
  • reversals

The idea is to compute the minimum number of operations that it would take to transform one string into another. The longest common substring problem follows with the following constraints:

  • substitutions are forbidden
  • only exact character match, insert, and delete are allowable edit operations

References

181 questions
0
votes
0 answers

Struggling to make Longest Common Subsequence code parallel (C)

Currently trying to make code finding the longest common subsequence of two given strings. I have got the code working serially, however I have been tasked for homework to implement OpenMP and OpenMPI (not worried about this yet). My main goal is to…
jksk
  • 3
  • 2
0
votes
1 answer

Longest common substring via suffix array: uses of sentinel

I am reading about the (apparently) well known problem of the longest common substring in a series of strings, and have been following these two videos which talk about how to solve the problem using suffix arrays: (note that this question doesn't…
Wad
  • 1,454
  • 1
  • 16
  • 33
0
votes
1 answer

Find multiple longest common leading substrings with length >= 4

In Python I am trying to extract all the longest common leading substrings that contain at least 4 characters from a list. For example, in the list called "data" below, the 2 longest common substrings that fit my criteria are "johnjack" and "detc".…
Stanleyrr
  • 858
  • 3
  • 12
  • 31
0
votes
1 answer

Extract longest common path between two lists in python

Lets say there are two lists L1=[['A', ['C', ['B', ['D', 0]]]], [['A', ['D', ['K', ['C', ['E', 0]]]]], [['A', ['C', ['B', ['M', 0]]]]] and L2=[['A', ['C', ['B', ['K', 0]]]], [['A', ['C', ['B', ['B', ['E', 0]]]]], [['A', ['D', ['K',…
0
votes
0 answers

length of longest consecutive elements of sequence

I am trying to find a way to get the code to determine the longest length of sequences in common between two sequences. Example: So if we had sequence A: 12343241234132142 and sequence B: 231232412431. The answer would be 32412, hence 5 elements in…
CatM
  • 284
  • 2
  • 12
0
votes
1 answer

Common Subsequence in Different Length Arrays

I've implemented a DP algorithm that finds the longest common subsequence in three arrays. The problem though, is that my algorithm doesn't work when the arrays are of different lengths, and I have no idea why. From what I can tell, my algorithm is…
0
votes
2 answers

Find the longest unique strings from list of strings python

I have a list of strings These strings are made up of strings that will be contained within other strings And Strings that are Unique in the longest iteration For example in my list might have the following…
Jack Walker
  • 238
  • 1
  • 2
  • 10
0
votes
2 answers

Why is this code not executing properly? Longest substring problem

So I'm trying to solve the Longest Substring Without Repeating Character problem in a webpage and when I'm trying to upload it it will show me this bug: class Solution { public int lengthOfLongestSubstring(String s) { HashSet hash =…
Manu Carba
  • 139
  • 2
  • 8
0
votes
1 answer

Find the length of the longest common substring in 'n' binary strings

I am given n strings (n>=2 and n<=4) and each one is constructed using 2 letters only: a and b. In this set of strings I have to find the length of the longest common substring that is present in all the strings. A solution is guaranteed to exist.…
user9681811
0
votes
0 answers

Finding max common substrings in 2 strings using Hash and Binary search

Suppose I have 2 big strings of size 10^5, How can I search for max common sub strings from both strings with complexity O(NlogN) using Hash and Binary Search. Explanation with code will be of great help :)
pshashi04
  • 222
  • 2
  • 12
0
votes
1 answer

this code in python about finding the longest sub-string , i need explaination

i am trying to understand how this code works behind the scene , help appreciated explain this part please: MAX = ACCOUNT if len(ACCOUNT) > len(MAX) else MAX ACCOUNT = ACCOUNT + c if c >= ACCOUNT[-1] else…
Abou Menah
  • 947
  • 1
  • 6
  • 9
0
votes
2 answers

How to find the longest substring that occurs in every element of an array?

I have a collection of texts from some authors. Each author has a unique signature or link that occurs in all of their texts. Example for Author1: $texts=['sdsadsad daSDA DDASd asd aSD Sd dA SD ASD sadasdasds sadasd @jhsad.sadas.com sdsdADSA…
mrmrn
  • 33
  • 6
0
votes
1 answer

Longest Common Subsequence program throws a string index out of range error

I have two strings str1 = "bqdrcvefgh" str2 = "abcvdefgh" I want to find the LCS between the two strings.But I am encountering string index out of range exception.This is my code str1 = "bqdrcvefgh" str2 = "abcvdefgh" #taking str1 as column and str2…
Souvik Ray
  • 2,899
  • 5
  • 38
  • 70
0
votes
3 answers

problems with indexes in a searching code

I have made the following Java code for searching for the longest substring that is common between a pair of strings. The code is as follows: public static void main(String[] args) { // TODO code application logic here String…
Little
  • 3,363
  • 10
  • 45
  • 74
0
votes
1 answer

Index and length must refer to a location within the string.?

My input strings are inputData = "99998UNKNOWN" inputData = "01000AMEBACIDE/TRICHOM/ANTIBAC 1" inputData = "34343AMEBACIDE/TRICHOM/ANTIBACSADWA1" ID = inputData.Substring(0,5); Name = inputData.Substring(5,30); Level =…
Subash A
  • 33
  • 1
  • 1
  • 5