Skip to main content

All 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 ...
st0n3r's user avatar
  • 73
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 ...
Ruiru's user avatar
  • 21
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 ...
BlazeRod11's user avatar
-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 ...
driver's user avatar
  • 232
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 ...
Aryaman 's user avatar
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 ...
driver's user avatar
  • 232
-2 votes
2 answers
141 views

Lower-Bound algorithm getting Time Limit Exceeded

...
Shakhawat Hossain SHIHAB's user avatar
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 ...
Szyszka947's user avatar
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 ...
Loki Astari's user avatar
  • 95.4k
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 ...
A15's user avatar
  • 23
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: ...
Nicolò Teseo's user avatar
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 ...
Harry's user avatar
  • 429
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 ...
Sam's user avatar
  • 61
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) ...
Vaibhav Vishal Singh's user avatar
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 ...
circuital's user avatar

15 30 50 per page
1
2 3 4 5
15