All Questions
Tagged with time-limit-exceeded c++
215
questions
2
votes
1
answer
108
views
Codeforces: Dasha & Nightmares
so I got started with competitive programming about a day ago and I got stuck on the first random question I tried on codeforces. It's called Dasha and Nightmares.
Problem Description:
The problem ...
2
votes
1
answer
745
views
Traveling Salesman Problem for visiting cities
Implement TSP problem using best first algorithm (so it will be
backtracking, branch-and-bound, and best-first). Since you are looking
for a cycle, the start/finish city is not important. Therefore we
...
4
votes
2
answers
118
views
Find largest sum not involving consecutive values
There is a question to basically find the largest sum in an array, such that no two elements are chosen adjacent to each other. The concept is to recursively calculate the sum, while considering and ...
-2
votes
1
answer
56
views
Market Portfolio Binary Search Tree [closed]
I'm trying to solve the following problem here:
First line of input contains the number of days D. The next d lines contains a character c and a number x. If c is B, then buy stock . If c is S, then ...
4
votes
2
answers
589
views
O(nlogn) Lexicographically minimal rotation code but tle on this particular case
Based on a small suggestion here , this code tries to find lexicographically minimal rotation (question) by successively comparing two adjacent substrings in the very left , that can potentially give ...
3
votes
1
answer
1k
views
Knock down tall buildings
I'm trying to solve the following problem:
As you know Bob likes to destroy the buildings.
There are N buildings in a city, ith building has ai floors.
Bob can do the following operation.
Choose a ...
-2
votes
2
answers
141
views
2
votes
2
answers
95
views
For two sequences N and M, display counts of elements n from N below each m from M up to the first n above m
A school's task:
There are two sequences n_tab and m_tab.
For every element m in m_tab ...
4
votes
2
answers
304
views
Wildcard Matching: LeetCode 44
Follow up post
Link to question:
Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where:
'?' Matches any single character.
'*' Matches ...
2
votes
2
answers
95
views
Print the count of input numbers less than each of mutiple values "q"
I was solving a question in a competition I joined that asked for a program that calculates how many numbers are less than \$q\$. I solved the question but didn't get the full mark because the code ...
5
votes
2
answers
980
views
Find the best couple of an array in 1.5 seconds
I faced this exercise.
Given a sequence \$S\$ (\$2 <= |S| <= 10^6\$) of numbers (\$1 <= S_x <= 10^7\$), determine \$max(abs(S_i - S_j) + abs(i -j))\$.
Here is the solution I found:
...
3
votes
2
answers
292
views
Find pairs of similar (by hamming distance) bit strings
I have a list of binary strings where each binary string max length is 15. I need to find list of integers which is count of similar (should differ by max 1 bit position) binary strings present in the ...
6
votes
2
answers
767
views
Codeforces #806 Problem D: Double Strings
I tried solving the following problem by following the suggested approach to solving the problem in the problem tutorial. However, the online judge still says my solution exceeds the time limit. Is ...
2
votes
2
answers
792
views
Subarrays with length
You are given an array A of length N (where N is as large as 2×105). All elements of the array are positive integers less than or equal to N. Determine the count of subarrays (contiguous subsequences) ...
1
vote
1
answer
213
views
Infix calculator programming challenge Kattis.com
I'm working on this C++ coding problem:
Input is a sequence of up to commands, one per line, ending at
end of file. Each command is a definition, a calculation, or a clear.
All tokens within a ...