Skip to main content

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.

9 votes
2 answers
917 views

Prime generator for SPOJ

I have written code to solve the prime generator problem. I am given an input which contains in the first line the number of test cases, and for each test case, I am given a range and I have to print ...
Mansuro's user avatar
  • 221
2 votes
3 answers
1k views

LeetCode 49: Group Anagrams

I'm exceeding the time limit for a 10,000 word test case provided on LeetCode: Given an array of strings, group anagrams together. For example, given: ...
boltthrower's user avatar
151 votes
17 answers
20k views

Disproving Euler proposition by brute force in C

I wrote a little bit of code to brute force disprove the Euler proposition that states: $$a^4 + b^4 + c^4 = d^4$$ has no solution when \$a\$, \$b\$, \$c\$, \$d\$ are positive integers. I'm no ...
Aidenhjj's user avatar
  • 2,373
14 votes
2 answers
3k views

O PC, why are you so slow?

In order to test some software I've written, I need to write values to a test harness with OLE for Process Control (OPC). The problem is, for a larger range of values I'm generating points for (say ...
syb0rg's user avatar
  • 21.8k
12 votes
4 answers
13k views

Finding the first duplicate in an array

My code returns the correct answer the first duplicate is 3 (represented as int f) . I am struggling finding a more efficient way to find the first duplicate? My ...
Andrew Mattick's user avatar
9 votes
5 answers
6k views

Euler #3 largest prime factor

Problem Statement This problem is a programming version of Problem 3 from projecteuler.net The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of a given number N?...
G V Sandeep's user avatar
8 votes
2 answers
6k views

BFS shortest path for Google Foobar "Prepare the Bunnies' Escape"

This is the Google Foobar puzzle "Prepare the Bunnies' Escape": You have maps of parts of the space station, each starting at a prison exit and ending at the door to an escape pod. The map ...
oxtay's user avatar
  • 183
7 votes
4 answers
6k views

Hacker Rank - Poisonous Plants

I have the solution for the problem, but it is taking me 7 seconds to run on a large dataset. I am trying figure out a better way of doing this. It has to run in under 3 seconds. Problem Statement: ...
PushCode's user avatar
  • 233
4 votes
2 answers
7k views

Codewars: Sum of Pairs

I've been working on this task (see screenshot). Here's my answer to it so far: ...
chiich's user avatar
  • 79
4 votes
1 answer
394 views

Counting ways to fit bottles in crates

I'm calculating how many possibilities there are to fit \$n\$ identical bottles inside \$k\$ crates of various capacities. n = Number of bottles k = Number of crates K = List of the number of bottles ...
Deniz Alz's user avatar
3 votes
1 answer
569 views

HackerRank New Year Chaos: arriving at a given list using neighbor swaps

I am trying to solve the HackerRank New Year Chaos problem where the aim is as follows: A vector of size n is having values ...
RC0993's user avatar
  • 141
2 votes
2 answers
766 views

Printing all the prime numbers between two bounds

I keep getting a time limit exceeded for this solution to SPOJ Prime1. I need to print all primes within a given interval (with intervals as large as 105, and numbers as large as 109). I've tried ...
user6607's user avatar
  • 377
1 vote
2 answers
258 views

Closest Pair of Points - Optimizing Code for big sets of points

I'm trying to create an algorithm that finds the closest pair of points (2D) within a set of points. I'm using a divide and conquer method which is explained here Closest Pair of Points Algorithm. ...
Lamett's user avatar
  • 11
18 votes
5 answers
3k views

Flipping coins performance

This is the Flipping coins problem on CodeChef: There are \$N\$ coins kept on the table, numbered from \$0\$ to \$N - 1\$. Initially, each coin is kept tails up. You have to perform two types of ...
Ukiyo's user avatar
  • 283
14 votes
4 answers
4k views

2-sum problem on a range in Python

Here is the problem description (from an algorithm course: https://www.coursera.org/learn/algorithm-design-analysis): The goal of this problem is to implement a variant of the 2-SUM algorithm (...
David Michael Gang's user avatar

15 30 50 per page
1
2 3 4 5
7