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.

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 ...
user avatar
2 votes
1 answer
134 views

Count how many numbers in a range have exactly three divisors

The challenge Given array a of n numbers, I need to count how many positive numbers less than each aᵢ have exactly 3 divisors. Constraints 1 <= aᵢ <= 2.5 * 10¹³ In other words, the minimum ...
Muhammad Usman's user avatar
2 votes
1 answer
181 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 ...
user12138762's user avatar
2 votes
1 answer
68 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) ...
user24714692's user avatar
3 votes
1 answer
147 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 ...
DuesserBaest's user avatar
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 ...
DuesserBaest's user avatar
6 votes
1 answer
328 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 (...
user24714692's user avatar
4 votes
2 answers
495 views

Leetcode: Steps to Make Array Non-decreasing

I was trying out leetcode's Steps to Make Array Non-decreasing As per the challenge's description: You are given a 0-indexed integer array nums. In one step, remove all elements nums[i] where nums[i ...
ccot's user avatar
  • 341
1 vote
3 answers
113 views

Find min sum for indices to match equation

I want to reduce time complexity of my code: I have an array of integers arr say [1, 2, 3, 6, 67] I have an equation : a*x+b*y=z, I can use the array values in this ...
Learner's user avatar
  • 217
9 votes
4 answers
2k views

Leetcode : First Missing Positive

I was trying out leetcode's first missing positive. As per the challenge's description: Given an unsorted integer array nums, return the smallest missing positive integer. You must implement an ...
ccot's user avatar
  • 341
1 vote
3 answers
127 views

Maximum Sum BST in a Binary Tree

I was trying to find the Maximum sum BST of a binary tree on LeetCode. While the Java code I have come up with, mostly seems right and is able to pass 55 out of the given 59 test cases too, the error ...
Siddharth Garg's user avatar
2 votes
1 answer
80 views

Sort array of numbers using tree sort - Leetcode 912

Problem statement: Sort integer array nums in O(N log N) time, without relying on any library sort routine. I am trying to use a tree sort method (using the ...
qxzsilver's user avatar
  • 123
4 votes
2 answers
113 views

Delete a node in binary tree

Problem Statement Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST. Basically, the deletion ...
iskander's user avatar
  • 121
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? ...
Subha Rajagopal's user avatar
2 votes
1 answer
62 views

SEDE query to count questions, views and unanswered for a set of tags

This query selects the number of SO questions, the number of views and the number of unanswered questions for each tag (the list of the tags is the user input). It works fine when it works, but it ...
Yulia V's user avatar
  • 635

15 30 50 per page
1
2 3 4 5
71