# 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.

861 questions
Filter by
Sorted by
Tagged with
76 views

### VBA Excel Looping through recordset and storing the data to use later

I have a loop to add Recordset items to a Dictionary so I can do comparisons and retrieve specific data later in the code (not ...
131 views

### “Food Ordering” program exceeds time limit in test 9

So, I've recently started working on CodeForces to practice from older contests (and maybe even start participating in current ones), but there is one problem that I can't seem to make an efficient ...
225 views

### Largest Prime Factor of Number in PHP or QBasic [closed]

I was solving the 3rd problem at Project Euler which requires me to calculate the largest prime factor of 600851475143 which I think is a really large number (more than 6 billion). QB64 At first, I ...
88 views

### Calculating sum after ranged-based subtractions

The puzzle consists from something like this: You will receive an array of integer with values, then you will receive X numbers. Each number (call it x) represents ...
168 views

### Splitting many data files by quintile

The program below is about finding the values below the percentage and splitting them into five different output files. This works great for small input data files. But when I am trying to run it for ...
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 ...
68 views

### Read coordinates from many files and calculate polygon areas

My goal with this snippet is to create an array of coordinates which in turn is a tuple of 68 elements, area and modified area array for all 10k elements and assign it to the ...
95 views

### Prime number generation - SPOJ

This is a program to generate prime numbers for a given range. The sieve of Eratosthenes algorithm was implemented, but still the SPOJ says time limit exceeded. Where can some optimizations be made? ...
8k views

### Read a CSV file and do natural language processing on the data

I am studying the techniques of data mining and data processing. I'm doing this through data I've collected and stored in a csv file. The problem is that this filed was very large, to the point of ...
81 views

### Recovering permutation from its image sequence

Recently while practicing I came across this problem , here is an excerpt from it, A permutation of the numbers 1, ..., N is a rearrangment of these numbers. For example 2 4 5 1 7 6 3 ...
634 views

### Partitions of a number (backtracking) - time efficiency

I had to write an algorithm that prints the partitions of a natural number in lexicographic order. Example of I/O: If the algorithm reads from ...
130 views

### Finding the maximum of an array to solve a rope-burning puzzle

I am trying to get the maximum value out of this array. There is a long rope of length totalLength at its each unit length some ropes are tied pointing in upper ...
225 views

### Fast sums of power algorithm

This code reaches time limit on 1 test case, solving this challenge. The approach that I'm using is from the book Algorithms Functional Programming Approach, which is a backtracking depth searching ...
65 views

### Optimal BST challenge

I was coding the problem here. I think I have solved it, but I ran into time limit exceeded issues. I am new in Competitive Programming, so I was looking for a better, time efficient logic for solving ...
319 views

### Solution to Codejam 2019's Pylons

I'm trying to solve Pylons from the 2019's round 1A. Problem Our Battlestarcraft Algorithmica ship is being chased through space by persistent robots called Pylons! We have just teleported ...
70 views

### Euler Project #3 Largest prime factor timeout

I have been recently trying my hands on Euler's Project through HackerRank and got stuck with project #3 where you have to find the Largest Prime Factor. Question: The prime factors of 13195 are 5, 7,...
44 views

### Incrementing specified list values, with “catch-up” [closed]

I completed a coding challenge recently in which my function was to be given two parameters: N, the number of counters to be used (numbered 1 through N) - and A, an array of integers. Iterating ...
58 views

Problem Statement: FOXLINGS It’s Christmas time in the forest, and both the Fox and the Wolf families are celebrating. The rather large Fox family consists of two parents as well as $N$ ($... 2answers 687 views ### Blackjack strategy simulation I'm very new to python (been coding for about two days) and have created a programme that simulates blackjack games so that I can work out optimal strategy over many iterations. The problem is that ... 1answer 83 views ### Listing all possible names from a phone number In the program we have to input a number and then calculate all the possible name we can form according to the following rule: ... 2answers 627 views ### Checking if all possible combinations of any two array elements in an array contains 0-9 atleast once I am coding for an online platform. The code is working on some test cases but is getting a Time limit exceeded. What are the ways to make my code more efficient? Input ... 1answer 1k views ### Generating and finding parent nodes in a post-order tree Given a height h and list q of integers, list the parent node of each element in q, if nodes are read in post-order sequence ... 1answer 102 views ### Project Euler - #5 smallest multiple (Ruby using a hash table) Why will this code work for a smaller multiple like 10 but time out for anything over 13? Can this code be revised to work for larger numbers? (I have an alternate solution but wanted to see if this ... 1answer 633 views ### Select random IDs from a table, using MySQLi I've created a "simple" function that receives a MySQLi resource and, using a custom where query, will fetch random IDs from a provided table. Some caveats on this:... 1answer 216 views ### Effective ways to find partial sha1 collision I need to find 2 different string and compare their hash value. Both string must contain "abc". I looking for the first eight character that are the same and stop. I have been running for more than 24 ... 1answer 106 views ### jQuery-loaded financial report taxes the browser I load a table in a div using the .load() method. If I look on the console I see the times taken to display the table: 4.98 seconds that firebugs says are spent "... 2answers 664 views ### Uva Online Judge problem 100, 3n + 1 I am having a tough time submitting this code to UVa Online judge and having it pass. I keep getting the message - Your program used more CPU time than what is allowed for this problem. That means ... 0answers 70 views ### Leetcode Word break 2 I am trying to solve this question Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid ... 0answers 512 views ### Function to sum values of most significant digit contained ABOUT For each subsequence, look at its position in the original decimal representation of$x$. Let's say that the most significant digit it contained was the$e$-th digit, where$e=0$... 1answer 467 views ### CodeChef Matches challenge I am solving some problems from CodeChef but I am stuck on the Matches problem: Ari and Rich are playing a pretty confusing game. Here are the rules of the game: The game is played with ... 1answer 52 views ### Time limit exceeded in K-th symbol in Grammar (LeetCode) I am taking efforts to solve problem K-th Symbol in Grammar - LeetCode K-th Symbol in Grammar On the first row, we write a 0. Now in every subsequent ... 0answers 138 views ### The number having odd divisors between 2 numbers I am trying to solve a problem from Hackerearth. I'm able to solve sample testcases but somehow when I am submitting the solution it gives time limit exceeded error or wrong output message. Problem ... 0answers 139 views ### Hackerrank All Women's Codesprint 2019: Visually Balanced Sections Link: https://www.hackerrank.com/contests/hackerrank-all-womens-codesprint-2019/challenges/visually-balanced-sections/problem Problem Description A rack has$n$horizontal compartments. The ... 0answers 45 views ### Counting events that occur in some time intervals I have a python code where I need to count the number of ids in a given range of timestamps as : ... 0answers 252 views ### Time limit exceeded on HackerRank “Username Disparity” Here is the hackerrank question: For two strings A and B, we define the similarity of the strings to be the length of the longest prefix common to both strings. For example, the similarity of ... 2answers 213 views ### Largest prime factor function I have written a function which finds the largest prime factor of some number. This function works but the problem is that it is too slow. For instance, when I enter 600851475143 as a parameter, the ... 2answers 244 views ### Lattice path from Project Euler with Python solution I was trying to solve this problem called lattice path from Project Euler: Count the number of unique paths to travel from the top left to the bottom right of a lattice of squares. How many such ... 0answers 37 views ### Program that uploads and process excel files current limit is 20,000 lines My program is called "Cleaner". What it does is that we have a "Dirty" excel file with a good number of lines in it around 20,000 - 400,000 lines. The process of cleaning the records is basically ... 2answers 465 views ### “Spread the Word” CodeChef challenge I am solving the "Spread the Word" problem on CodeChef: Snackdown 2019 is coming! People have started to spread the word and tell other people about the contest. There are$N$people numbered 1 ... 3answers 125 views ### Calculating the max difference between any 2 numbers from an array How can I make this little program work a little faster? The task is to calculate the max difference between any 2 numbers from an array of numbers. Target time is 1 sec, now it works in 1.1 sec. I'... 2answers 364 views ### Fastest way to find maximum deviation I acknowledge that this exact question was asked here. I was working on the same problem from the same website. I had the same question and consulted the above as a reference, however with respect ... 3answers 162 views ### Writing many cells to sheet causes Excel to not respond, replacing vlookups [closed] I have found that my code causes my Excel to 'not respond' when it gets to this for loop, For thisRow = 2 To lastWSrow(outWS). I'm guessing this is because I am ... 2answers 891 views ### Coursera: Calculating sum of numbers in the fibonacci sequence between two specific points in the series Question This is an assignment for a Coursera course. This is the algorithm I wrote. ... 1answer 199 views ### Project Euler Problem #23 (non-abundant sums) [closed] Project Euler Problem 23 A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of$28$would be$1 + 2 ...
832 views

What I need to accomplish is matching the QR code to the one I have created. This code works, except it takes at least 30 seconds to verify that it has matched my QR Code. How can I make it faster? ...
332 views

### Project Euler Problem 1 with Python 3 ideal solution

I have been playing around in hacker rank with Python these days, and now pulling my hair out on this question to solve the Euler's problem in the least time required. If we list all the natural ...
45 views

### Macro to clear cells that do not appear in a master list

The macro below clears cells that do not match any cell in comparison to a range (a master list). It works on small file but is too slow to work for files with large ranges. ...
111 views

### MySQL select between MAX-n1 AND MAX-n2

I just made this link please check this out Online Results I need to select data between 2 values from a table by using MAX because each SID has different VID. My code: ...
The given code gives correct output but exceeds the time limit and I have no idea how to optimize it. I know it is of $O(n^2)$ complexity but I am not able to get anywhere near to optimizing it. ...