Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
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.
6
votes
1
answer
2k
views
MaxCounters solution
I am doing this Codility problem
You are given N counters, initially set to 0, and you have two possible operations on them:
increase(X) − counter X is increased by 1,
max counter − all …
4
votes
1
answer
290
views
High execution time to count overlapping substrings
I was doing this HackerRank problem which basically boils down to counting overlapping substrings in a string. I used this solution from StackOverflow to build this program -
def overlapping_occurre …
5
votes
2
answers
1k
views
High execution time of LCS length program in Python2
I was trying to solve the Longest Common Subsequence problem on a HackerRank exercise.
It's quite simple and straightforward, just print out the length of the LCS. I submitted this code:
s1 = raw_in …
2
votes
2
answers
3k
views
Counting pairs of integers which have a predefined difference
I'm doing this HackerRank problem:
Given \$N\$ integers, count the number of pairs of integers whose difference is \$K\$.
So far, I've ended up with this code:
def countPairs(ar, n, k):
ar. …
3
votes
Counting pairs of integers which have a predefined difference
Okay, so I solved the problem. It seemed like the while loop DID have O(n^2) complexity. I changed the function countPairs() to this:
def countPairs(ar, n, k):
ar.sort()
i = 1
j = 0
c …
3
votes
2
answers
592
views
Time limit exceeded on finding out the GCD and LCM of a Python list
I'm doing this HackerRank problem:
Consider two sets of positive integers, \$A=\{a_0, a_1, \ldots, a_{n-1}\}\$ and \$B=\{b_0, b_1, \ldots, b_{m-1}\}\$. We say that a positive integer, \$x\$, is be …
1
vote
Accepted
Time limit exceeded on finding out the GCD and LCM of a Python list
It turns out my count function was inefficient. Going through the discussion forms on the site, I found this which passed all the test cases -
def count(l, g):
count = 0
for i in xrange(l, g …
2
votes
2
answers
106
views
High execution time on number partitioning program in Python 2.7
I am writing a program to count only the partitions of a number with distinct parts.
I am using a bottom-up approach to dynamic programming to generate partition lists from previously obtained partiti …
5
votes
1
answer
2k
views
Count words with given prefix using Trie
I have been trying to solve this HackerRank problem:
We're going to make our own Contacts application! The application must perform two types of operations:
add name, where is a string denoting a c …