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
1 answer

Longest Common Sub-sequence using a recursive list

I am trying to find the the Longest Common Sub-sequence between two things of type comparable. I have the algorithm down, but I could like to add these items to a list via a recursion method call, but I do not know how I would add the last item to…
Vnge
  • 1,295
  • 25
  • 49
0
votes
2 answers

re to find longest matching postfix of two strings

I have two strings like: a = '54515923333558964' b = '48596478923333558964' Now the longest postfix match is c = '923333558964' what will be a solution using re? Here is a solution I found for prefix match: import re pattern =…
sharafjaffri
  • 2,134
  • 3
  • 30
  • 47
0
votes
3 answers

Find arbitary patterns common to a group of strings

Background: I am developing a program in that iterates over all the movies & tv series episodes stored on my computer, rates them (using rotten tomatoes) and sorts them in order of rating. I extract the movie name by removing all the unneccessary…
Kevin
  • 4,070
  • 4
  • 45
  • 67
-1
votes
2 answers

can i fill a used hashmap with zeros after its been used? C programming

im asked to build a function that finds the longest substring with no repeating characters in a given string. this is gonna be a 2 in 1 question bc i want to now if my approach is correct and if "emptying" a hashmap is possible.i used this code: int…
-1
votes
1 answer

Find all possible patters in list of no and the position of the pattern break

input has list of nos output has all the possible pattern occurring and the position where the pattern break input [1,2,3,1,2,3,1,2,3,4,1,2,3,10,5,6,4,5,6,8,4,5,6,12,2,3] output [1,2,3]: 10th position and 14th [4,5,6]:20th position and…
KS HARSHA
  • 67
  • 2
  • 7
-1
votes
3 answers

How to find longest common substring of words in a list?

I have a list of words: list1 = ['technology','technician','technical','technicality'] I want to check which phrase is repeated in each of the word. In this case, it is 'tech'. I have tried converting all the characters to ascii values, but I am…
-1
votes
1 answer

Longest Substring Without Repeating Characters: Wrong answer

I have sent hours trying to find out the reason why the method returns a wrong answer for this particular test case: "qrsvbspk". The method returns 6 instead of 5. I cannot figure out what is wrong. Plz help! Here's my approach: class Solution { …
msbtech
  • 21
  • 3
-1
votes
1 answer

Python - Longest substring having only matched parentheses

For interactive parsing purposes, given an input string I need to extract the longest possible substring starting at index 0 and having only matched parentheses. Example (LISP-like s-expressions) Input string: (print "hello") (assign a (+ c d))…
-1
votes
1 answer

What is the importance of passing pointer in the function?

Why pointer X and Y have to be passed in the lcs function? Also what is going wrong when instead of a pointer an array is passed. #include #include int max(int a, int b); int lcs( char* X, char* Y, int m, int n ) { if (m == 0…
zaxcode
  • 17
  • 3
-1
votes
1 answer

Longest String you can form by adding one character at a time to an input string

So I got this question in an interview recently: Given a dictionary and a starting string, what is the longest word you can form by adding one character at a time to the front and back of input string, with every new word must also appear in the…
-1
votes
2 answers

Find Longest common subsequence : my method

I am trying to implement the Longest common sub sequence of 2 strings. My method is bit different than posted here. I am near the solution but little problem. Please help me. My problem: Desired Output: metallica current output: etallica My code is…
Aditya Peshave
  • 103
  • 2
  • 2
  • 9
-2
votes
1 answer

My "Longest Common substring with at most k mismatches" algorithm with O(m*n) space complexity is giving wrong answers with large string inputs

I am new to this platform so please bear with me. My program was based on the longest substring problem with no mismatches using Dynamic Programming. Here is a link to the D-P…
-2
votes
1 answer

longest common sequence instead of word

i am using a list and iterating from last to first element of the strings to find the longest common sub word between them. So the value for the current iteration(LC[i][j]) will depend both on the previous iteration LC[i+1][j+1] and the current…
ps3790
  • 1
  • 4
-3
votes
1 answer

Longest common sub string and sub sequence

Can anyone clearly explain recursive solutions of Longest common subsequence and longest common substring and the difference between them?
-4
votes
1 answer

print the longest word and ignore the numbers

i'm trying to print the longest word from a string and to ignore the number, so even though the number is the longest, it will print the longest word. let userInput = "print the longest word 3372838236253 without number"; function…
orela123
  • 11
  • 2
1 2 3
12
13