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
1
vote
2 answers

Specifying end of string sentinels in Python prior to constructing a suffix array

I'm implementing algorithms in http://portal.acm.org/citation.cfm?id=1813708 that utilize suffix arrays to find longest common substrings. The algorithms involve constructing a suffix array for a string that is the concatenation of a set of given…
Chris
  • 3,109
  • 7
  • 29
  • 39
1
vote
1 answer

Finding *modal* substring of a list of strings in python

Finding a common substring has been answered in many questions, i.e. given a list of strings find the (typically longest or largest number of words) substring that is common to all of them. See here: Longest common substring from more than two…
sfortney
  • 2,075
  • 6
  • 23
  • 43
1
vote
1 answer

rosalind solution fixing: shared motifs

I am aware that there are solutions for rosalind challenges but I do not want them to spoil the fun. I thought I found a solution for "Finding a shared motif" yet my answer is wrong all the time. The question is about finding the longest common…
Fırat Uyulur
  • 149
  • 1
  • 11
1
vote
2 answers

Efficiently finding the longest matching prefix string

My current implementation is this: def find_longest_matching_option(option, options): options = sorted(options, key=len) longest_matching_option = None for valid_option in options: # Don't want to treat "oreo" as matching "o", …
naiveai
  • 590
  • 2
  • 14
  • 42
1
vote
1 answer

Longest Common Substring without Dynamic programming or Suffix Tree

Skiena's Algorithm Design Manual Question 8-3 part b asks to give a "simpler" BigO(nm) algorithm for finding the longest common substring that does not rely on dynamic programming. The obvious answer seems to be to use a suffix tree, however, Skiena…
Jose Villalta
  • 1,457
  • 1
  • 12
  • 20
1
vote
1 answer

Find largest substring of numbers within a tolerance level

I have the following input: a tolerance level T Number of numbers N N numbers The task is to find the longest period within those N numbers such that they are within the tolerance level. More precisely, given a left and a right bound of a…
Dr3w Br1ck13
  • 187
  • 1
  • 5
  • 14
1
vote
0 answers

Finding non-overlapping repeating sub-strings

My problem is similar to finding the longest repeating non-overlapping sub-strings but in this manner. Example, my input array is 0,0,0,1,2,1,1,2,1,1,2,1,2,0,0 The longest repeating and non-overlapping sub-string in this input is 121 with the count…
user3552407
  • 361
  • 1
  • 4
  • 14
1
vote
1 answer

Find longest common substring of array of Strings

In my Swift 3.0 app, I want to determine the best name for something by finding the longest common substring of 6 to 12 strings. Example strings: ON/OFF office lights DIM office lights VALUE office lights FB office lights FB VALUE office…
Bram Roelandts
  • 470
  • 7
  • 25
1
vote
1 answer

Retrieve the longest matching value from a list by matching with another list [Python 2.7]

There are two lists to be matched, li_a is the given list consists of sequence of characters of a sentence, whereas li_b is the collection of words. li_a = ['T','h','e','s','e','45','a','r','e','c','a','r','s'] li_b =…
Htet
  • 159
  • 10
1
vote
2 answers

longest common subsequence java (recursive)

The problem I'm working on is here: http://practiceit.cs.washington.edu/problem/view/cs2/sections/recursivebacktracking/longestCommonSubsequence basically we are given two strings and we are requested to find the longest common subsequence. I've…
Amber
  • 21
  • 1
  • 6
1
vote
0 answers

Longest common substring large strings?

I need some help with this function. I am trying to find the longest common string between 2 strings. Here is the function that I am currently using: Public Shared Function LCS(str1 As Char(), str2 As Char()) Dim l As Integer(,) = New…
Zach Johnson
  • 2,047
  • 6
  • 24
  • 40
1
vote
1 answer

Ruby longest palindrome

I'm trying to solve the longest palindrome problem in Ruby, and I found the answer on stackoverflow: ANSWER: Suppose the string has n characters. First see if the entire string is a palindrome. If it is, return the string. Fini! If not, see if…
iswg
  • 195
  • 1
  • 10
1
vote
2 answers

r which rows have longest partial string match between two vectors

I have two vectors that contain the names of towns, both of which are in different formats, and I need to match the names of water districts (water) to their respective census data (towns). Essentially for each row in water, I need to know the best…
Chris Heckman
  • 121
  • 1
  • 1
  • 7
1
vote
1 answer

DNA sequencing using python

Using loops, how can I write a function in python, to sort the longest chain of proteins, regardless of order. The function returns a substring that consists only of the character 'A','C','G', and 'T' when ties are mixed up with other elements:…
HandyFrank
  • 13
  • 4
1
vote
4 answers

Is there anyway to repeat the biggest segment of continuous segment of repeat using php?

I want to put the input like "RKKRRRRK" and try to get the output like largest continuous segment.. Suppose my input may be "RKKKR" then my program will display 'KKK' is the largest continuous segment.. and then it also display the count is 3.. I've…
Vengat CsEngg
  • 27
  • 1
  • 5