Skip to main content

All Questions

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 (...
user24714692's user avatar
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
183 views

k-dice Ways to get a target value

I'm trying to solve the following problem: You have a k-dice. A k-dice is a dice which have k-faces and each face have value written from 1 to k. Eg. A 6-dice is the normal dice we use while playing ...
driver's user avatar
  • 232
1 vote
2 answers
160 views

Making my DP algorithm faster - longest palindromic substring

The following code is my solution to a LeetCode question - find the longest palindromic substring. My code is 100% correct, it passed once but it took too long, and in most of the reruns I hit a "...
ela16's user avatar
  • 113
3 votes
1 answer
262 views

Longest Palindromic Substring | Python Code Giving TLE

Problem Statement Given a string s , return the longest palindromic substring in s. Constraints ...
Rohit Singh's user avatar
2 votes
2 answers
2k views

HackerRank: Sam and substrings | How can dynamic programming be used in my code?

Given a number as a string, no leading zeros, determine the sum of all integer values of substrings of the string. Given an integer as a string, sum all of its substrings cast as integers. As the ...
No Name's user avatar
  • 147
4 votes
5 answers
807 views

Find maximum value of recursively-defined "fusc" function

I've been trying this question from SPOJ, which asks for the user to enter a number n, and they will receive a maximum fusc value that lies in between 0 to ...
user avatar
1 vote
1 answer
236 views

Target Sum array using Dynamic Programming

I'm learning Dynamic Programming and trying to solve this Target Sum array problem. I've to find an array of integers that sums to a given target sum using the integers of given input array. I've used ...
Harry's user avatar
  • 429
3 votes
1 answer
3k views

Recursive solution of ordered Coin Combinations II (CSES)

Question Link Consider a money system consisting of n coins. Each coin has a positive integer value. Your task is to calculate the number of distinct ordered ways you can produce a money sum x using ...
randomUser's user avatar
1 vote
2 answers
342 views

Leetcode 377. Combination Sum IV Javascript Memoization attempt

Problem Statement ...
Prashin Jeevaganth's user avatar
0 votes
3 answers
467 views

Calculate sum of a substring

I try to solve some old Codeforces questions. The problem is; Petya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up q ...
Lady Be Good's user avatar
3 votes
0 answers
134 views

C++ - Longest Common Subsequence

Link to the Problem Here is my code to compute the length of the longest common subsequence of two integer arrays arr[] and brr[]...
White Tiger's user avatar
1 vote
2 answers
239 views

Recursive brute-force approach to maximum points you can obtain from cards

I came across this question on Leetcode. The question description is as follows: There are several cards arranged in a row, and each card has an associated number of points. The points are given in ...
Jitesh Malipeddi's user avatar
2 votes
1 answer
2k views

Maximum sum combination

I am trying to solve this question: https://www.codechef.com/problems/TADELIVE Andy and Bob are the only two delivery men of Pizza-chef store. Today, the store received N orders. It's known that ...
nz_21's user avatar
  • 1,041
0 votes
1 answer
593 views

Solution to knapsack problem exceeds time and RAM limits

My goal is to code the knapsack problem algorithm. The problem is that a knapsack has a given weight limit, W. I have a collection of items which have a given ...
DY92's user avatar
  • 141

15 30 50 per page