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.

Filter by
Sorted by
Tagged with
6
votes
2answers
3k views

Efficient implementation of a Dynamic Programming challenge

I wrote the following code for a Dynamic Programming problem but the online judge gives me a 'Time Limit Exceeded' error. How can I optimize this code to make it more efficient, especially the part ...
3
votes
2answers
800 views

UVA 10474 - “Where is the marble?” time limit

I have a problem from UVA online judge here. I have read it tons of times, and as they said, I have to get the answer really fast. I have used a binary search and ...
2
votes
1answer
300 views

“Unfriendly Number” challenge

I tried to solve the Unfriendly Number problem on InterviewStreet: There is one friendly number, K, and N unfriendly numbers. We want to find how many numbers are there which exactly divide the ...
2
votes
2answers
504 views

Optimization in overcoming TLE in interviewStreet problem

I have been trying to get the problem Quadrant Queries correct for a while now. Although my approach is an optimal one, I am getting a TLE on 3 test cases. Please help me optimize my approach so that ...
3
votes
1answer
304 views

Mathematical programming puzzles

This is a solution I wrote for a programming puzzle which I believe and I'm sure is correct, but for two of their test cases the online judge gives me 'Time Limit Exceeded' only by a few 100ms! I've ...
5
votes
2answers
2k views

Handling addition of two binary numbers

This code is for handling addition of two binary numbers, which can be as long as 100,000 bits... and up to 500,000 queries are performed. High-level pseudocode: First input ...
3
votes
1answer
3k views

Output strings from a set in lexicographical order

Puzzle Description: You are given 'n' strings w1, w2, ......, wn. Let Si denote the set of strings formed by considering all unique substrings of the string wi. A substring is defined as a ...
7
votes
1answer
1k views

Optimizing string match algorithm

I was trying to solve this problem. I thought of any possible relation between the number of matches among subsequent substrings, but could not find one. So, the probably naive solution that I ...
0
votes
1answer
747 views

Comparing rows of a matrix with some row vectors

I have run this program for five hours and it has not yet completed. I wonder if we can make changes to reduce the computation time. I use several for loop and this greatly increases the computation ...
5
votes
2answers
6k views

Finding the next palindrome of a number string

Here is the problem: A positive integer is called a palindrome if its representation in the decimal system is the same when read from left to right and from right to left. For a given positive ...
5
votes
1answer
6k views

Time Limit Exceeds [HS11DIVS] - How to make it faster?

Here is the question. From SPOJ [HS11DIVS]. Now , the problem is that my code works perfectly for small numbers. But when it comes to Large numbers , the time limit exceeds. I am not getting any hint ...