All Questions
Tagged with time-limit-exceeded python
391
questions
6
votes
8
answers
1k
views
Reversing vowels in a string
Given a string s, reverse only all the vowels in the string and return it.
The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both lower and upper ...
2
votes
1
answer
185
views
Hackerrank "New Year chaos" solution - permute sequence by swapping adjacent terms
I was doing the Hackerrank "New Year chaos" problem. Here is the description:
It is New Year's Day and people are in line for the Wonderland
rollercoaster ride. Each person wears a sticker ...
2
votes
1
answer
69
views
Clique Connect: minimum spanning tree
Problem Statement
You are given a weighted undirected graph G with N vertices, numbered 1 to N. Initially, G has no edges.
You will perform M operations to add edges to G. The i-th operation (1≤i≤M) ...
3
votes
1
answer
152
views
Performance Tuning to enable answer for Project Euler #566 "Cake Icing Puzzle"
Related to this question I am still looking for a solution to Project Euler Problem 566 (see link for a nice simulation also):
Adam plays the following game with his birthday cake.
He cuts a piece ...
2
votes
1
answer
101
views
Project Euler #566 "Cake Icing Puzzle" Performance Tuning
I am rather new to python and wanted to use Project Euler to learn more about it. The task can be seen here, so I will skip any description of my own:
Project Euler Problem 566 (see Link for a nice ...
6
votes
1
answer
329
views
Codeforces: D2. Counting Is Fun (Hard Version)
The code works okay for the following problem.
Problem
An array 𝑏 of 𝑚 non-negative integers is said to be good if all the elements of 𝑏 can be made equal to 0 using the following operation some (...
2
votes
3
answers
737
views
Find median value of two Sorted Arrays
To improve my coding knowledge can you please give me suggested changes on my code?
...
1
vote
1
answer
87
views
HackerRank Algorithm Problem: Climbing the Leaderboard (Python)
Here is the Hackerrank problem which is related to dense ranking and below is my solution which didn't pass the time limit cases. Any better way to optimize this?
...
3
votes
2
answers
303
views
Trailing Digits
https://www.acmicpc.net/problem/23204
I've solved a programming challenge where you need to count the occurrences of a specific digit at the end of the product of multiples of a given number within a ...
0
votes
1
answer
118
views
HackerRank Project Euler 12 (Python) | Highly Divisible Triangular Numbers
I again share my Python code which didn't pass time limit test cases in the HackerRank contest of ProjectEuler.
...
1
vote
1
answer
56
views
Find all combinations of two companies grouped by the projects they are tendering for
I am working on the task to get all possible combinations (pairs) of ID's (companies) which participated in one bid and create a new data frame with ID_1, ID_2, matching parameter (tender ID).
I have ...
9
votes
3
answers
2k
views
Repeatedly remove a substring quickly
I'm trying to solve the USACO problem Censoring (Bronze), which was the first problem for the 2015 February contest. My solution works for some test cases, but then times out for test cases 7-15. I ...
2
votes
1
answer
111
views
USACO Arithmetic Progression
The problem statement:
An arithmetic progression is a sequence of the form a, a+b, a+2b, ..., a+nb where n=0, 1, 2, 3, ... . For this problem, a is a non-negative integer and b is a positive integer.
...
1
vote
0
answers
112
views
USACO Silver "Wormhole Sort" solver
I'm struggling a bit with a USACO silver question using python, http://usaco.org/index.php?page=viewproblem2&cpid=992.
The question provides an unsorted list of numbers (cows) and a number of ...
2
votes
1
answer
166
views
Dijkstra's Algorithm + an additional cost to start at each node
I am trying to solve the 2009 Canadian Computing Competition Senior #4. The question gives you a map (graph) of different cities, and the cost of transporting something between each city. There are ...