Questions tagged [time-limit-exceeded]
When the code scales so poorly in the face of large inputs that it cannot complete in a reasonable amount of time, use this instead of the [performance] tag.
1,058
questions
4
votes
2
answers
789
views
LeetCode Daily Problem: Remove adjacent duplicated elements
I was doing an exercise from LeetCode in which consisted in repeatedly deleting any adjacent pairs of duplicate elements from a string, until there are only unique characters adjacent to each other.
...
7
votes
2
answers
1k
views
Find all combinations of length 3 whose sum is divisible by a given number
I came up with a suitable solution to a HackerRank problem that failed because the execution took longer than 10 seconds on lists that were of very large size.
The problem: Given a list ...
2
votes
2
answers
95
views
Print the count of input numbers less than each of mutiple values "q"
I was solving a question in a competition I joined that asked for a program that calculates how many numbers are less than \$q\$. I solved the question but didn't get the full mark because the code ...
1
vote
2
answers
160
views
Making my DP algorithm faster - longest palindromic substring
The following code is my solution to a LeetCode question - find the longest palindromic substring. My code is 100% correct, it passed once but it took too long, and in most of the reruns I hit a "...
6
votes
1
answer
590
views
HackerEarth challenge: Lunch boxes
I was solving the lunch boxes problem on HackerEarth but as I submitted my solution most of the test cases were passed and the rest showed 'Time Limit Exceeded'. I would be very grateful if you could ...
5
votes
1
answer
458
views
Connecting ropes with minimum cost
Question:
There are given N ropes of different lengths, we need to connect these ropes into one rope. The cost to connect two ropes is equal to sum of their lengths. The task is to connect the ropes ...
2
votes
1
answer
315
views
Pairwise Max Product
This python program takes user input of the number of elements in a list in the variable b and then takes user input of the list elements in list a. It then finds out the maximum product of a pair of ...
2
votes
1
answer
159
views
Efficient List comprehension with multiple conditions using shift? [closed]
I am new to python.
I am trying to get the total number of failures by checking first how did the transition of the column Failure Sensor. Then creating the Start column from devicetimestamp if the ...
1
vote
0
answers
69
views
Web-scraping bountied questions from Stack Exchange sites
I recently built my first web scraper in python, and decided to use SO and SE as test websites.
Code
...
5
votes
2
answers
980
views
Find the best couple of an array in 1.5 seconds
I faced this exercise.
Given a sequence \$S\$ (\$2 <= |S| <= 10^6\$) of numbers (\$1 <= S_x <= 10^7\$), determine \$max(abs(S_i - S_j) + abs(i -j))\$.
Here is the solution I found:
...
3
votes
2
answers
292
views
Find pairs of similar (by hamming distance) bit strings
I have a list of binary strings where each binary string max length is 15. I need to find list of integers which is count of similar (should differ by max 1 bit position) binary strings present in the ...
4
votes
4
answers
429
views
Find the missing and duplicated numbers from shuffled range
I'm solving "Unknown amount of duplicates. One missing number.":
In this kata, we have an unsorted sequence of consecutive numbers from a to b, such that a < b always (remember a, is the ...
3
votes
2
answers
406
views
Euler Project: Sums of Digit Factorials
MY CODE:
...
1
vote
2
answers
119
views
Sum of differences between products and LCMs
I've been trying to solve this Codewars problem https://www.codewars.com/kata/56e56756404bb1c950000992
In this kata you need to create a function that takes a 2D array/list of non-negative integer ...
5
votes
2
answers
572
views
Leet Code 139 (Word Break) using a trie with recursion
I was attempting to solve LeetCode 139 - Word Break
Given a string s and a dictionary of strings wordDict, return
...