All Questions
Tagged with programming-challenge dynamic-programming
84
questions
2
votes
5
answers
276
views
Sum of bitwise XOR of each subarray weighted by length
here is the problem statement
You are given an array a of length n consisting of non-negative integers.
You have to calculate the value of \$\sum_{l=1}^n \sum_{r=l}^n f(l,r)\cdot (r - l + 1)\$ where \...
1
vote
1
answer
1k
views
Leetcode 55. Jump Game solution
I was working on Jump Game problem on leetcode
Question
You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your ...
3
votes
1
answer
2k
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 ...
1
vote
2
answers
342
views
Leetcode 377. Combination Sum IV Javascript Memoization attempt
Problem Statement
...
3
votes
1
answer
218
views
Killing a Hydra - Overengineered
Background
This question is inspired by the question: Killing a hydra, and my response therein. I will restate the problem at hand in full so that this question is fully self contained
You can only ...
1
vote
2
answers
121
views
I want reduce the time complexity for this ladder problem to find the minimum ladders required
I was trying to attempt below given challenge. I tried multiple ways to solve the problem but none of them were good enough to pass the time limit. Please advise if you have any idea to improve on ...
1
vote
0
answers
64
views
LeetCode: range sum query mutable c#
https://leetcode.com/problems/range-sum-query-mutable/
I am trying to solve this question using dynamic programming.
I guess the guys in leetcode want to limit us to use segment tree or one of the ...
3
votes
0
answers
131
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[]...
3
votes
0
answers
309
views
LeetCode: Stone Game C#
https://leetcode.com/problems/stone-game/
Alex and Lee play a game with piles of stones. There are an even
number of piles arranged in a row, and each pile has a positive
integer number of stones ...
1
vote
1
answer
1k
views
Code A Primitive Calculator ( x3,x2,+1) Using Dynamic programming [closed]
Question -You are given a primitive calculator that can perform the following three operations with the current number 𝑥: multiply 𝑥 by 2, multiply 𝑥 by 3, or add 1 to 𝑥. Your goal is given ...
9
votes
1
answer
2k
views
LeetCode on Longest Palindromic Substring in Python
This is a programming question from LeetCode:
Given a string s, return the longest palindromic substring in s.
Example 1:
Input: s = "babad" Output: "bab" Note: "aba" is ...
0
votes
1
answer
453
views
LeetCode 1320: Minimum Distance to Type a Word Using Two Fingers II
I'm posting my Python code for LeetCode's 1320. If you have time and would like to review, please do so.
Problem
You have a keyboard layout as shown above in the XY plane, where each English ...
1
vote
1
answer
150
views
LeetCode 1320: Minimum Distance to Type a Word Using Two Fingers I
I'm posting my C++ code for LeetCode's 1320. If you have time and would like to review, please do so. Thank you!
Problem
You have a keyboard layout as shown above in the XY plane, where each English ...
-1
votes
1
answer
359
views
LeetCode 375: Guess Number Higher or Lower II
I'm posting my C++ code for LeetCode's Guess Number Higher or Lower II. If you have time and would like to review, please do so.
Problem
We are playing the Guess Game. The game is as follows:
I pick ...
1
vote
2
answers
238
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 ...