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.

learn more… | top users | synonyms

1
vote
1answer
13 views

Matching lines in a CSV file with items in a dictionary

I was wondering if there was a better way of writing this... I have a CSV file (about 6640 lines). After reading through the file, the values for the DFN_Network ...
2
votes
0answers
21 views

Selecting the most recent record for each product

I have the following structure of a table: ...
2
votes
2answers
265 views
4
votes
2answers
33 views

Number of ways to make change for an amount

Task Write a program that, given the amount to make change for and a list of coins prints out how many different ways you can make change from the coins to STDOUT. My approach The number to make ...
3
votes
0answers
39 views

Getting contacts from phone is taking too much time

I am working on an instant chat messaging application. I am getting contacts from phone and displayed them in list view of an activity, but it is taking 25-30 seconds using the following code: 1. On ...
9
votes
2answers
106 views

Finding all contiguous sublists such that each member appears an even number of times

The program needs to find all contiguous sublists of numbers where the number of occurrences of every member in the contiguous sublist is divisible by 2. The first line of input is N (the number of ...
5
votes
3answers
97 views

Compose valid subtractions using all digits from a set

I have created a brainteaser, which I called the "impossible problem" (see this video I made). The aim is to create a valid 3-digit subtraction which uses every digit from 1 to 9 once. Here is an ...
4
votes
1answer
43 views

Segmented Sieve of Eratosthenes in Scala

I'm trying to solve PRIME1 in SPOJ with the following Scala snippet: Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between ...
3
votes
1answer
51 views

Clojure reverse multiple times

I have a piece of Clojure code that reverses a string recursively. It is working but too slow (because I got the problem from Codewars and I cannot validate it ...
9
votes
5answers
234 views

Pizza Hut math problem #1 in Haskell

I'm currently attempting to learn Haskell after a fair history of imperative programming. When I saw the Pizza Hut Pi Day math problems, I thought the first one would be a good candidate for my ...
1
vote
1answer
32 views

Quickly find percentile with high precision

I need to find the percentile where a list of values is higher than a threshold. I am doing this in the context of optimization, so it important that the answer is precise. I am also trying to ...
4
votes
2answers
63 views

Counting numbers whose digits all go up or down

I have created a program which takes a value x and uses this value to create a power of ten value like so 10 ** x. This has ...
1
vote
1answer
49 views

Finding Kth Permutation Sequence

I have written a program to display the kth permutation sequence of a string made up of letters 'O' and 'Z' . I tried optimizing it but my code have not passed test cases due to timeout issues.Looking ...
7
votes
0answers
207 views

Decompose polarimetric SAR covariance matrices in MATLAB

I want to apply the following code on 3 images of the sizes 676×718, 1430×1440, and 5576×9444, but the code is too slow even for the 676×718 image. ...
1
vote
1answer
38 views

Finding the percentile corresponding to a threshold

I need to find which percentile of a group of numbers is over a threshold value. Is there a way that this can be speed up? My implementation is much too slow for the intended application. In case this ...
3
votes
1answer
63 views

DFS algorithm too slow

I am practicing my coding on leetcode, and my submission, although correct for small cases, is timing out for large ones. Could you please let me know how to improve my code? The question is as ...
4
votes
1answer
325 views

Time limit exceeded for java “insertion sort linked list”

I was working on LeetCode to practice myself with Java programming. I encountered a question about insertion sort a linked list. My code currently runs correctly, but it failed on an instance with ...
6
votes
3answers
66 views

Korean word segmentation using frequency heuristic

This a continuation of a previous question. I want to thank Joe Wallis for his help with increasing the readability of my code. Although the changes made by Joe Wallis did increase the speed of the ...
5
votes
1answer
96 views

How to lose plants and aggravate people

Courtesy of a few posts around here I've discovered HackerRank. Poisonous Plants is one of their challenges. Of course, skip the following if you'd like to try it yourself. Challenge: There are ...
3
votes
1answer
75 views

Redirecting arriving customers to the nearest empty queue

I have a task to make a checkout line controller. First it receives, as input, an amount of checkouts and commands. Then commands that are C for coming and L for leaving, and after those the number of ...
1
vote
1answer
65 views

Code to analyse text get stuck if too much data

I've made the following VBA script to analyse text recurrence in a huge batch of descriptions. For a small part of the batch the code run smoothly, but when I include everything it tends to loose ...
2
votes
1answer
67 views

Performance of the String searching algorithm

I am trying to solve a string matching question mentioned here. I recently learned the Knuth–Morris–Pratt algorithm and tried to implement it to solve this question. But I am getting a TLE for this ...
0
votes
0answers
434 views

Solution to King Kohima problem in Python

King Kohima problem: King Kohima has reserved a new exclusive street for his executive class employees where they can build their homes. He has assigned you to plan that street. You have to ...
1
vote
2answers
106 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 ...
4
votes
1answer
192 views

Hacker rank Jesse and Cookies

I am trying to solve a problem in hacker rank and the question is as follows: Jesse loves cookies. He wants the sweetness of all his cookies to be greater than value \$K\$. To do this, Jesse ...
4
votes
2answers
108 views

Sort a stack of numbers in ascending order only using push

I have a stack of numbers ranging from 1 to 1 million representing a pile of numbered DVDs. Given the stack in random order I am to sort the stack by only taking an element from the stack and push it ...
6
votes
2answers
44 views

Creating a list of new areas for patches of conserved land within a watershed

I'm writing code to create a list of new areas for patches of conserved land within a watershed based on the current size distribution of conserved land patches that are in the watershed now. I'm ...
14
votes
6answers
670 views

Counting numbers with specific digits

The challenge: Suppose you are inhabitant of a planet where 1, 7, and 9 are lucky digits. A lucky number for you is a number that contains only your lucky digits in it. For ex: 1, 79, 911, 9917 ...
4
votes
2answers
67 views

Find all integers between m and n whose sum of squared divisors is itself a square

Divisors of 42 are : 1, 2, 3, 6, 7, 14, 21, 42. These divisors squared are: 1, 4, 9, 36, 49, 196, 441, 1764. The sum of the squared divisors is 2500 which is 50 * 50, a square! Given two ...
2
votes
1answer
92 views

Hackerrank challenge - Dictionaries and Maps in Erlang

This question is really similar to an existing one in Ruby. So the task is also the same: Day 8: Dictionaries and Maps! The problem is that on Hackerrank my solution only passes the first and last ...
0
votes
2answers
86 views

Optimization of Factorial Function

This is solution to codechef problem FCTRL2 where we are supposed to find the factorial of numbers upto 100. I have tried several techniques but I am always exceeding their time limit (1 second). ...
2
votes
3answers
162 views

Wet Boxes problem: counting points on a triangular grid

As a solution to the B. Wet Boxes problem : B. Wet Boxes Bob works in a warehouse which contains a large pile of boxes. The position of a box can be described with a pair of integers (x, ...
3
votes
2answers
109 views

Check if sum can be found in array

Given an array a, check to see if z numbers inside a total up to ...
3
votes
3answers
83 views

Searching a string for any permutation of words

Given a string and an array of words, return all indexes in string for which a concatenation of all words in the array, in any order (so ["eensie", "weensy", "spider"] has six orderings) can be ...
5
votes
1answer
51 views

Computing the de Bruijn sequence

I'm trying to compute de Bruijn sequences for alphabets which have a number of characters which is a power of two. So the sequence must contain every possible subsequence of length \$N\$ from \$0\$ to ...
5
votes
2answers
153 views

Project Euler problem 530 - GCD function is inefficient

Here is a description of Project Euler problem 530: Every divisor \$d\$ of a number \$n\$ has a complementary divisor \$n/d\$. Let \$f(n)\$ be the sum of the greatest common divisor of \$d\$ ...
10
votes
2answers
184 views

Project Euler Problem 530: sum of sum of greatest common divisors

Here is a description of Project Euler problem 530: Every divisor \$d\$ of a number \$n\$ has a complementary divisor \$n/d\$. Let \$f(n)\$ be the sum of the greatest common divisor of \$d\$ ...
4
votes
1answer
113 views

Hackerrank - “Sherlock and the Beast”

I solved the problem but for two test cases, it's giving me timeout error. It's taking longer than 2 seconds on their servers. I tried using <ctime> to ...
5
votes
1answer
61 views

Calculating diagonal difference

I was trying to solve a problem concerning the difference of the diagonal sums of a matrix (using C99): ...
10
votes
3answers
124 views

Project Euler Problem 10. Sum of all primes < 2mil

I'm new to coding so I can't create complex code yet. I do as much as I can with fors and ifs, since while I know a bit about ...
8
votes
2answers
350 views

Finding indexes of numbers that sum to a target

I've taken this algorithm question, which is to find the indexes of any two numbers in an array that sum to a given number. It is quite a simple problem to solve. But it is the execution time of my ...
4
votes
1answer
536 views

Deleting millions of rows from a MSSQL server table

This SQL query took 38 minutes to delete just 10K of rows. How can I optimize it? Index already exists for CREATEDATE from ...
5
votes
1answer
115 views

“Changing Bits” challenge

Problem Statement: Let A and B be two N bit numbers (MSB to the left). You are given initial values for A and B, and you have to write a program which processes three kinds of queries: ...
3
votes
1answer
72 views

Scanning multiple huge files in Python (follow-up)

I'm trying to implement an algorithm able to search for multiple keys through ten huge files in Python (16 million of rows each one). I've got a sorted file with 62 million of keys, and I'm trying to ...
9
votes
1answer
425 views

Scanning multiple huge files in Python

I'm trying to implement an algorithm able to search for multiple keys through ten huge files in Python (16 million of rows each one). I've got a sorted file with 62 million of keys, and I'm trying to ...
6
votes
2answers
106 views

A recursive program that attempts to solve an extremely large number

This is my recursive program for the following function: \$F(x) = G(x) - W(x)\$ \$G(x) = [G(x-1)+G(x-2)]^2\$ \$W(x) = [W(x-1)]^2 + [W(x-2)]^2\$ If x == 0 in either function G or function W, then ...
1
vote
2answers
110 views

Calculating the energy of a signal

I have a program to read signal data from 120 files in a folder and performing the energy of the signal. It works correctly, but execution time is more than 20 mins, so there may be a problem with ...
3
votes
1answer
55 views

Finding the largest not-necessarily contiguous alternating binary string after inverting any sub-string from a given string

I'm having problems solving this problem within the time limit. Alternative Thinking http://codeforces.com/contest/603/problem/A Kevin has just recevied his disappointing results on the USA ...
10
votes
3answers
336 views

Optimization on Sieve of Eratosthenes using vector<bool>

I am solving this prime generator problem from SPOJ: Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between two given ...
5
votes
1answer
100 views

Processing weather station data using idw - Follow Up

New Approach My previous question may have had a little too much going on and I realized I could simplify the problem by constructing the data a bit differently thanks to @Gentian Kasa . Previously, ...