All Questions
6 questions
2
votes
2
answers
237
views
Generate the number of partitions of each integer
I've coded a program that calculates the number of partitions of n into at least two distinct parts, and is relatively quick too (about N^1.5 complexity). For input 30 000 it takes roughly 4 seconds. ...
6
votes
2
answers
238
views
LeetCode 126: Word Ladder II -- Memory limit exceeded
I am trying to solve LC126, and got a memory limit exceeded for the following solution.
I've seen the answer here -- so I'll try to use Dijkstra as well, but I would like to understand why I get the ...
6
votes
2
answers
117
views
Program for activity selection exceeds time limit
I've been trying to solve this problem for some while and the solution I have come up with exceeds the lime limit by 1-3 ms and 2 out of 10 tests get a memory issue error. Why is that? This is the ...
7
votes
2
answers
191
views
Prime number segmented sieve
I tried to solve the SPOJ prime number problem below. The code produced correct results, but Time limit exceeded and also memory need around 970M which is not efficient(?)
How can I optimize this ...
5
votes
1
answer
2k
views
C++11 : simple Tree implementation
I have created a C++11 implementation of a simple Tree for an online code challenge,
I'd like to know how to improve it and how to make my code use less memory :
...
3
votes
3
answers
493
views
Calculating number of unharmed leaves
I recently came across this problem that asks you to print the number of leaves not eaten by the caterpillars:
As we all know caterpillars love to eat leaves. Usually, a caterpillar
sits on leaf, ...