All Questions
Tagged with time-limit-exceeded java
170
questions
4
votes
2
answers
497
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 ...
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 ...
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 ...
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 ...
6
votes
1
answer
127
views
One or more planets to line up with the earth a certain amount of times
I have attempted the below question, however my solution is too slow (i.e. It does not fit the 2 second time constrain for java). How can the solution be optimised?
While at IOI 2020 in Singapore, ...
2
votes
1
answer
135
views
Find character at given index in a sorted sub strings [closed]
For a given string say dbac the possible substrings are [d,db,dba,dbac,b,ba,bac,a,ac,c]. Sort them and concatenate to a string: ...
0
votes
1
answer
301
views
HackerRank "Digit sum" challenge
Here's the question:
...
3
votes
1
answer
268
views
Highly divisible triangular number
Highly divisible triangular number, my solution
My solution of challenge from Project Euler takes too much time to execute. Although on lower numbers it works fine. Anyone could look up to my code and ...
1
vote
1
answer
184
views
CSES Number Spiral Java TLE
I am trying to solve the CSES Number spiral problem
https://cses.fi/problemset/task/1071/
However, I get the TLE problem. How can make my code more efficient?
...
1
vote
1
answer
210
views
Finding longest palindromic substring in a string (gives TLE on leetcode)
I'm solving the Longest Palindromic Substring problem on LeetCode.
And here's my final submission:
...
2
votes
1
answer
278
views
Codechef: The Chefora Spell
This is the question currently I am trying to solve of codechef and I am able to get the given test cases result but I am getting Time Limit Exceeded when I am trying to submit. Please let me know ...
3
votes
1
answer
89
views
Java i/o speed less than python i/o while printing an array
Motivation: I was solving an array based i/o problem and encountered Time Limit Errors, it was later found that the code for java ran roughly 10x slower than the ...
2
votes
2
answers
604
views
CSES - Number Spiral - Java TLE
My java code for CSES Introductory problem Number Spiral gives TLE for large inputs, like
Input :
100000
170550340 943050741
121998376 943430501
689913499 770079066
586095107 933655238 …
(First line/...
3
votes
1
answer
314
views
Prime factorisation in java
I came across this question in a coding contest (Java-restricted) and I got TLE. I am unable to provide the link of the question as the contest is closed now. Can I know how can I optimise this?
Four ...
3
votes
0
answers
197
views
Count unique subsequences
I came across this question in a coding competition (Java-restricted) and I got a time-length-exceeded. I am unable to provide a link as the contest is closed now. Can I know how can I optimise this?
...