All Questions
Tagged with time-limit-exceeded strings
50
questions
4
votes
2
answers
589
views
O(nlogn) Lexicographically minimal rotation code but tle on this particular case
Based on a small suggestion here , this code tries to find lexicographically minimal rotation (question) by successively comparing two adjacent substrings in the very left , that can potentially give ...
3
votes
1
answer
262
views
Longest Palindromic Substring | Python Code Giving TLE
Problem Statement
Given a string s , return the longest palindromic substring in s.
Constraints
...
1
vote
1
answer
210
views
Finding longest palindromic substring in a string (gives TLE on leetcode)
I'm solving the Longest Palindromic Substring problem on LeetCode.
And here's my final submission:
...
2
votes
2
answers
984
views
InterviewBit Problem: Stringoholics
I am trying to solve this InterviewBit problem.
Problem Statement:
You are given an array A consisting of strings made up of the letters
‘a’ and ‘b’ only. Each string goes through a number of ...
4
votes
1
answer
494
views
strstr implementation with python and sets
Please review my strstr implementation in terms of time/space efficiency and overall readability. I am preparing for a coding assessment coming up as I am looking to pivot my career from Physics to ...
1
vote
0
answers
295
views
Algorithm for building a string by appending and cloning substrings [closed]
I have a problem where I need to construct a given string from scratch for a minimum cost by either:
Appending a new character for a cost A
Appending a substring of my existing string for a cost B
...
6
votes
1
answer
146
views
Search for strings in a list that have > 90% similarity
Explanation:
I am working on String comparison in which I want to cross-compare the list of the same input string.
For the same string, I am continuing the loop but if a single string will have ...
4
votes
3
answers
4k
views
Morgan and a String HackerRank challenge
I am solving a HackerRank problem called 'Morgan and a String'. Given two strings, each consisting of up to 105 uppercase characters, the task is to form the lexicographically smallest string from ...
2
votes
1
answer
390
views
Longest Common Prefix of string
Can anyone help me remove TLE (time limit exceeded) from this?
Given integer n and array of string of length n. In each query (q of them) we are given l and r and we need to find LCP in this ...
2
votes
2
answers
10k
views
Count palindrome substrings
Given a string S, count and return the number of substrings of S that
are palindromes. Single length substrings are also palindromes. We
just have to count the substring that are palindrome.
...
4
votes
4
answers
11k
views
Checking whether one string contains all the characters of another string
I am working on a CodeWars kata that requires the code to run under a certain time limit. This code passes all the tests; but, it doesn't run fast enough. I don't know what else I can trim down or ...
4
votes
2
answers
121
views
Adding input strings and finding occurrences of certain prefixes
A user inputs data using a keyword add word and when he wants to find words with particular prefix then he enters find keyword.
...
4
votes
1
answer
834
views
Checking whether strings are permutations of each other in Swift
I'm solving this problem on Hacker Earth, just for practice. The exercise is to determine whether two given equal-length strings are permutations of each other.
Except for this one test case, which ...
1
vote
1
answer
56
views
Add spaces around variable with $ symbol bookends
I have some code in a particular coding language, and I am trying to clean it up by adding spaces around the variables. I wrote this code, and it works on small amounts of text and if I set a break ...
5
votes
2
answers
5k
views
HackerRank Similar String
Problem Statement: https://www.hackerrank.com/challenges/similar-strings
I got the logic correct. However it times out for testcase 8 onwards
I would like some suggestions on optimizing this code
<...