Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

0 votes
0 answers
12 views

Finding Longest Palindromic Substring, solution is too inefficient but I am not convinced dp is more efficient in this case

I have a solution which is O(n^2). My idea loop through each character of the given string and find longest possible odd and even substring which results in a palindrome. Why does my solution take so ...
Arno.B's user avatar
  • 35
3 votes
3 answers
159 views

Longest Repeating Subsequence: Edge Cases

Problem While solving the Longest Repeating Subsequence problem using bottom-up dynamic programming, I started running into an edge case whenever a letter was repeated an odd number of times. The goal ...
William Edwardson's user avatar
0 votes
0 answers
72 views

How to efficiently compute similarity scores for prefixes of a string with another string in C?

I'm working on a problem involving string matching where I need to compute the similarity scores for each prefix of a string C against another string S. The similarity score for a prefix P of C and S ...
NatsumiStar's user avatar
1 vote
2 answers
477 views

Pick K letters to build as many strings as possible

I stumbled upon this question and I'm unable to solve it. Any help is much appreciated. You are given an array S made of N strings and an integer K. Choose at most K letters from the alphabet that ...
user23374150's user avatar
0 votes
0 answers
262 views

Optimal Cost Calculation for String Construction with Append and Clone Operations in C++

Problem Overview: I'm working on a string construction challenge where I aim to build a target string from scratch. The process involves two primary operations: Appending any character to the current ...
Wayne's user avatar
  • 1
0 votes
1 answer
56 views

Finding the subset of a dictionary that has the minimum edit distance to a given string

I'm looking for the most efficient way of solving an Levenshtein edit distance problem. We are given as input: A set of strings S of size n <= 8, with average length m <= 50 A target string t ...
Mathguy's user avatar
  • 157
1 vote
2 answers
147 views

How do I cast a String to a Long-int in C?

How do i turn a String in C to a Long integer, without removing the leading zero? I have used both sscanf() and strtol() functions but they both remove the leading zero as if its white-space. I have ...
El Barto's user avatar
2 votes
2 answers
175 views

Finding the sum of Digits expressed as a string of Letters [duplicate]

I have a string str of lowercase letters in the range [a-z]. Few letters of the string when combined together, represent a digit from [0-9] i.e. "zero" = 0, "one" = 1, "two&...
htaritoyj's user avatar
0 votes
5 answers
422 views

Efficiently searching for custom objects in large Python lists

I have a list of custom Python objects and need to search for the existence of specific objects within that list. My concern is the performance implications of searching large lists, especially ...
SyntaxNavigator's user avatar
0 votes
1 answer
67 views

Error in running a test case In LONGEST COMMON SUBSTRING

I need to solve a question that asks for code finding the longest common substring between 2 strings: My code is not running for one test case given below: 17 60 KXCGMTMVVGFQQWSPD ...
Prashant Rai's user avatar
2 votes
0 answers
170 views

Count occurrences of subsequence in all substrings of string

I want to write an algorithm that counts the total number of (disjoint) occurrences of a subsequence of characters within all substrings of a string. An example is below. String: "jabcohnnyjohnny&...
jp99's user avatar
  • 21
1 vote
1 answer
402 views

Minimum amount of flips required to make binary strings match, under the restriction that there must never be three of the same bit consecutively

Imagine you have two binary strings, a and b, given as input. a and b are both of the same length. The objective is to find the minimum number of flips required to make a equal b, WITHOUT a ever ...
d0057b5bfe0ab457028b6ce41b86b6's user avatar
2 votes
1 answer
187 views

Number of Palindromic Substrings- error in dynamic programming

I'm trying to solve the number of palindromic substrings problem using DP. The problem requires us to find the number of palindromic substrings in a string. My current code is as follows: def ...
testing09's user avatar
  • 137
-1 votes
3 answers
208 views

How to make a dynamic string?`I want to get a string dynamically but i don;t what to use it like this: string = (char*)malloc(100 * sizeof(char)); [closed]

#include<stdio.h> #include<string.h> int main() { char string[100]; printf("Enter string: "); fgets(string, 100, stdin); return 0; } Or we can also do something ...
Manvi Koul's user avatar
0 votes
2 answers
77 views

Is character array size dynamic in C/CPP/C++?

My knowledge till now was that arrays in C and CPP/C++ have fixed sizes. However recently I encountered 2 pieces of code which seems to contradict this fact. I am attaching the pics here. Want to hear ...
Arunavo Biswas's user avatar

15 30 50 per page
1
2 3 4 5
10