192 questions
1
vote
1
answer
42
views
Issues with Managing the Sliding Window in a JavaScript Function - Longest Substring Without Repeating Characters
I've been working on a JavaScript function to calculate the length of the longest substring without repeating characters. I encountered a couple of issues that I'm hoping to get some clarity on:
Using ...
2
votes
2
answers
54
views
JOIN two tables but only preserve results with longest substring match (Oracle SQL)
tables
I'm struggling to achieve the following.
I have a table of postal codes that includes full and partial postal codes. It will have other columns also.
In another table, I have locations, all ...
1
vote
2
answers
83
views
Find the most repeated sequence of chars in a list of domains
I have a very long list of domains (for example: blockme.com, do.remove-me.com.. etc) millions of them. I would like to use this list to create a list of regular expressions to cover as much as ...
0
votes
0
answers
91
views
How do I get the list of the longest common substrings with a minimum length in a Pandas DataFrame column of strings that is over 10000 entries?
So I have a pandas DataFrame where there are over 50000 rows. In one column, there is a list of strings that has no spaces, and is converted to lowercase, and there are multiple junk characters. The ...
0
votes
1
answer
120
views
Longest common subsequences, error when running code
`Here are the code and the error. I am not sure what to do for the declare any desired classes.
Traceback (most recent call last):
File "/home/runner/local/submission/main.py", line 149, in ...
2
votes
1
answer
108
views
Longest commong Substring from multiple strings
let lcs = (s, t) => {
let dp = Array.from({ length: s.length + 1 }, () => Array.from({ length: t.length + 1 }, () => 0));
let maxLen = 0, endIndexS = 0, endIndexT = 0;
...
1
vote
0
answers
108
views
Corner cases for Longest Common Substring problem?
I have been working on an exercise that gives two string s and t, find the longest common substring by outputting 3 integers: its starting position in s, its starting position in t (all 0-based), and ...
0
votes
2
answers
111
views
How to get count of max consecutive substring ab in given string abhwasababababuqabab
How to get count of max consecutive substring ab in given string abhwasababababuqabab
Input: abhwasababababuqabab
Output: 4 how?
We have 4 consecutive ab at middle from 6th index to 13th index. At ...
1
vote
1
answer
81
views
Longest common substring with restrictions
I have a function that finds and prints the longest common chain between two DNA chains. However I want to add some checks so my program can ignore characters that are not bases ('A', 'T', 'C', 'G')
...
1
vote
2
answers
322
views
Python program that finds the longest word in a sentence using list comprehension [closed]
Assume we have been provided with a string.
s="This is my statement"
We have to get sentence as an output and this needs to be solved using list comprehension concept.
I have tried the code ...
-1
votes
2
answers
64
views
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 "...
0
votes
3
answers
118
views
Why does this code work as expected if I use Visual C(Visual Sudio 2022) but doesn't if I use gcc 8.2?
I am new to C and still learning(currently doing some "LeetCode" challenges). I wrote a function that should return the longest common prefix in an array of strings. I tested with a couple ...
1
vote
2
answers
948
views
Find longest substring without repeating characters (LeetCode)
I am trying to solve this problem on LeetCode (https://leetcode.com/problems/longest-substring-without-repeating-characters/)
I got a code but i don't understand what's the problem with it.
def ...
0
votes
1
answer
61
views
determining a substring that is repeated in all of n strings and showing that substring in the output in java
i want to write a program that first takes the amount of n and then gets n strings (example: if n = 4 it gets 4 strings ) and then checks all the strings and finds the longest substring that contains ...
0
votes
0
answers
84
views
Known algorithms for incremental longest common substring?
Longest common substring is a well-known problem. I'm interested in identifying common substrings in a set of strings that is growing over time.
Use case: suppose I'm emitting log messages inside a ...
-1
votes
1
answer
37
views
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 ...
1
vote
3
answers
222
views
Python function that finds the shortest string in a string list or the lowest element of an integer list
I'm doing this exercise:
Write a Python program that gives two options to the user to either find the shortest
string in a string list or the lowest element of an integer list. The program should ...
2
votes
2
answers
418
views
How to print the longest sentence from a column in a csv file
I am very new to python and am really struggling with this problem. I have a csv file with different columns, labeled "height" "weight" "full_name" etc. I'm trying to ...
1
vote
0
answers
89
views
OCaml Longest common sequences (deep search)
Write with OCaml Longest Common Sottosequence (Deep Search)
Consider a finite set S of strings and an integer K. Determine, if it exists, a string x of length greater than or equal to K subsequence of ...
1
vote
1
answer
775
views
Find the longest common substring from two sentences
My question is how to find the longest common substring from two sentences.
For example:
sequence 1 = "there were a dozen eggs in the basket"
sentence 2 = "mike ate a dozen eggs for ...
0
votes
0
answers
114
views
Longest Common Substring from Trie
i'm trying to obtain the longest common substring from two strings and have coded a trie, but im not too sure how to obtain the longest common substring based on this trie. Could someone please help, ...
0
votes
1
answer
125
views
Where am I going wrong in the basic implementation of Longest Common Subsequence
I've tried to implement LCS in python using the following code, where am I going wrong ?
def lcs(s1,s2):
if len(s1) == 0 or len(s2) == 0:
return ""
n = len(s1) - 1
m ...
1
vote
1
answer
452
views
Longest Substring Without Repeating Characters - Need to Understand the Algorithm for given C# Solution
Problem: Longest Substring Without Repeating Characters.
I have this solution. But I do not have much of theoretical knowledge about DSA.
Trying to understand which algorithm it comes under and will ...
1
vote
0
answers
197
views
Longest substring not working for repeating characters
I have a fairly standard moving window function to find longest substring.
var lengthOfLongestSubstring = function (s) {
let currentString = [];
let longestStringLength = 0;
let ...
1
vote
1
answer
61
views
Find character at which string can be differentiated from list of strings
For every string in a df column, I need the character at which this string becomes unique, that is, its uniqueness point (UP). For illustration, here is a toy dataframe:
import pandas as pd
import ...
1
vote
0
answers
311
views
Memoization code for "Longest Common Substring" doesn't work as expected
I was able to think of a recursive solution for the problem "Longest Common Substring" but when I try to memoize it, it doesn't seem to work as I expected it to, and throws a wrong answer.
...
-1
votes
3
answers
2k
views
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 ...
1
vote
0
answers
14
views
XSLT Substring not woring [duplicate]
How to make XSLT substring-before second comma separate
for example the separator is ','
ex : Aban, aban, 22, 33
so the result should be
Aban, aban
and following numbers in other elements.
1
vote
1
answer
1k
views
The difference in application between SequenceMatcher in edit distance and that in difflib?
I know the implementation of the edit distance algorithm. By dynamic programming, we first fill the first column and first row and then the entries immediately right and below of the filled entries by ...
2
votes
1
answer
1k
views
Get closest match between sentence(represented as string) and list of phrases
Let me start with an example. Consider the following list in python
cities = [
'New york'
'San francisco',
'California',
'Las vegas',
'Chicago',
'Miami'
]
I also have ...
1
vote
1
answer
198
views
Tracing a recursive function for longest common substring
I am getting confused tracing the following recursive approach to find the longest common substring. The last two lines are where my confusion is. Specifically how is the count variable getting the ...
0
votes
1
answer
725
views
Recursion : Print all longest common subsequence
Iam trying to print all possible longest common subsequence using below code
1-Firstly i found LCS length dp matrix and trying using recursion to produce all possible outputs.
#####################...
0
votes
2
answers
2k
views
Trying to get the longest decreasing substring from a given string, keeping the case sensitivity in mind
I have been trying to get below result out of this Program but for some reason it is not giving the required output.
Required Results:
Input1 : bbaasssrppoccbaaacbaba Output1 : ['bbaa','...
8
votes
2
answers
2k
views
Longest substring that appears at least twice in O(n.logn)
Problem:
Given a String S of N characters (N <= 200 000), find the length of the longest substring that appears at least twice (the substrings can overlap).
My solution:
Here's what i've tried:
int ...
1
vote
4
answers
855
views
Concatenate array and return substring with longest repeating character
Let me preface with I AM A NEWBIE so take it easy on me please lol.
I need help writing a function that takes an array of words and returns an object with the letter and the length of the longest ...
0
votes
2
answers
395
views
Compare each element of two series/df with a custom function in pandas without a for-loop
I built a custom function two compare two url's to get the longest common subsequence (lcs).
def lcs_dynamic(url1, url2):
maths: compare url1 with url2
return lcs
I have a series s1 and a ...
0
votes
0
answers
136
views
Recursive solution to longest common substring not working
I am trying to get the longest common substring recursively but for some reason my code is not working.
def lcs(s, t):
if not s or not t:
return ''
if s[0] is t[0]:
return s[0]...
0
votes
0
answers
117
views
Longest Repeating Subsequence length in python using recursion producing wrong results
I am trying to generate the longest repeating subsequence but the output appears to be incorrect for a few cases.
Below is the code block I am using
def LRSLength(X, m, n):
# return if the end of ...
1
vote
2
answers
86
views
Finding contiguity by comparing kmers in R
Hello I have a dataframe which looks like this:
LR ID Kmer ProcID
1 GTACGTAT 10
1 TACGTATC 10
1 ACGTATCG 2
1 ...
0
votes
1
answer
81
views
Longest Common Subsequence not printing length matrix
I'm trying to implement Longest Common Subsequence algorithm in c, the matrices c[][] stores the length of the longest common subsequence, row[][] stores the parent block row in the c[][] matrix and ...
-1
votes
2
answers
718
views
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 ...
-4
votes
1
answer
149
views
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 ...
1
vote
2
answers
985
views
Count+Identify common words in two string vectors [R]
How can I write an R function that can take two string vectors and returns the number of common words AND which common words comparing element 1 from stringvec1 to element 1 of stringvec2, element 2 ...
2
votes
2
answers
2k
views
The longest repeating substrings JavaScript
I have a programm that can find the longest repeating substring of entered string, but the thing is, when there are 2 repeating substrings of the biggest length in answer I get only one of them.
For ...
0
votes
1
answer
35
views
Longest Palindrome Substring : Index Error ( list index out of range)
Index Error , List index out of range
In "if" statement, the second line gives the above specific error
You can see the value of index(ind) being used for the list(temp).
It is clearly not ...
2
votes
1
answer
1k
views
Longest repeated substring in massive string
Given a long string, find the longest repeated sub-string.
The brute-force approach of course is to find all substrings and check the substrings of the remaining string, but the string(s) in question ...
2
votes
1
answer
2k
views
longest palindromic substring using lcs?
I was solving this longest palindromic substring problem on leetcode and I followed the dynamic programming approach by creating one n*n boolean table(which I guess is also the standard solution to ...
1
vote
1
answer
299
views
Longest common prefix - comparing time complexity of two algorithms
If you comparing these two solutions the time complexity of the first solution is O(array-len*sortest-string-len) that you may shorten it to O(n*m) or even O(n^2). And the second one seems O(n * log n)...
-2
votes
1
answer
666
views
My "Longest Common substring with at most k mismatches" algorithm with O(m*n) space complexity is giving wrong answers with large string inputs [closed]
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 solution.
https://www....
0
votes
1
answer
94
views
whats the problem with the given solution to the LCS problem?
I have a recursive solution to the longest common subsequence problem of two strings given below:
def LCS(i, j, lcs): # i , j are the position of character in X and Y respectively which are being ...