All Questions
Tagged with dynamic-programming strings
16 questions
3
votes
1
answer
266
views
Longest Palindromic Substring | Python Code Giving TLE
Problem Statement
Given a string s , return the longest palindromic substring in s.
Constraints
...
1
vote
2
answers
140
views
0
votes
1
answer
373
views
Generate unique string permutations recursively
🧩 Objective
Write a recursive method for generating all permutations of an input string. Return them as a set.
See: Recursive String Permutations - Interview Cake
🔎 Questions
1: How does the ...
9
votes
1
answer
2k
views
LeetCode on Longest Palindromic Substring in Python
This is a programming question from LeetCode:
Given a string s, return the longest palindromic substring in s.
Example 1:
Input: s = "babad" Output: "bab" Note: "aba" is ...
1
vote
2
answers
110
views
A function to scan user input as string
I know that multiple functions are already available. However, I thought of writing my own because I wanted to learn the logic (and also because I thought there wasn't enough confusion :P). Please ...
1
vote
0
answers
128
views
How do I optimize memoization in order to find longest palindromic substring?
I want to find the longest palindromic substring using dynamic programming in Python3. The strings can be as large as this string.
I have seen other questions on this problem that successfully solve ...
2
votes
1
answer
78
views
Length of the longest common sub sequence bottom up
Could I get some feedback on this code? I included a test case as well.
This code computes the longest common sub sequence given paired data, it was not part of any challenge I just did it to learn ...
5
votes
1
answer
152
views
Identify fraudulent bank transactions
Task: Return true if a transaction is allowed and return false if transaction is prohibited.
Details:
1. String is represented as an "array" that can contain up to three elements.
We need to ...
3
votes
2
answers
1k
views
Counting the number of ways to decode a string
I am working on problem where I need to decode a string:
A message containing letters from A-Z is being encoded to numbers
using the following mapping:
'A' -> 1
'B' -> 2
...
...
2
votes
0
answers
1k
views
minimum window subsequence leetcode dynamic programming solution
Given strings S and T, find the minimum (contiguous) substring W
of ...
6
votes
2
answers
2k
views
Length of longest palindrome subsequence
I had an interview, where I was asked to solve to this question:
Given an string str, find the maximum length of palindrome subsequence.
Example: >if str = 'abcda':
maximum_length = 3 'aca'
How ...
3
votes
0
answers
787
views
Hackerrank: Sherlock and anagram (optimal time complexity)
Problem statement
Given a string \$S\$, find the number of "unordered anagrammatic pairs" of substrings.
Input Format
First line contains \$T\$, the number of testcases. Each testcase ...
3
votes
1
answer
111
views
Given two words, transform the first one into the second [closed]
As the title says, the problem I had to do sounded something like this:
We are given two words, S1 and S2. We must transform S1 into S2, using the following operations:
insert: insert a character in ...
2
votes
1
answer
574
views
Longest common substring using dynamic programming
I've written a short python script that attempts to solve the problem of finding the longest common substring using the dynamic programming technique. It is meant to be generalised so I could plug in ...
1
vote
1
answer
2k
views
Levenshtein distance with edit sequence and alignment in Java
I have this program that computes a Levenshtein distance of the two input strings, their edit sequence, and the alignment:
LevenshteinEditDistance.java:
...
3
votes
2
answers
881
views
Longest Common Subsequence and Longest Subsequence Palindrome
The following code computes:
The longest common subsequence between two strings, where a subsequence of a sequence does not have to consist of contiguous elements of the sequence.
The longest ...