Skip to main content

All Questions

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
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
3 votes
1 answer
221 views

LeetCode - Weekly Contest 213 - Kth Smallest Instructions

Hi I participated in Leetcode weekly contest 213 and am facing issue with submission for below question Kth Smallest Instructions Bob is standing at cell (0, 0), and he wants to reach destination: (...
Saitama's user avatar
  • 155
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
21 votes
3 answers
4k views

Loading military units into ships optimally, using backtracking

I solved the following problem using backtracking: We are given a list of military units, their weight and their (numerical) strength. We have a number of ships with a limited carrying capacity....
Jack's user avatar
  • 313
2 votes
3 answers
963 views

Looking for all numbers where each digit is bigger than the previous digit

This is the "Increasing Number problem", where we are looking for all numbers with \$n\$ digits where each digit is bigger than the digit before it. Or in Mathematical therms where: $$\mathit{...
Lucas Raphael Pianegonda's user avatar
4 votes
3 answers
8k views

Knapsack problem - recursive approach with memoization

This post is based on the 0-1 Knapsack problem. I came across this problem in Assignment #4 of Professor Tim Roughgarden's course Greedy Algorithms, Minimum Spanning Trees, and Dynamic Programming on ...
user avatar
3 votes
3 answers
385 views

Find k-distinct partitions which contain at least two perfect squares

Problem Statement: A k-distinct-partition of a number \$n\$ is a set of \$k\$ distinct positive integers that add up to \$n\$. For example, the 3-distinct partitions of 10 are \$1+2+7\$ \$...
Phoenix's user avatar
  • 387
3 votes
3 answers
2k views

Finding all possible paths between two points in a grid using recursion

I'm trying to find all possible paths made of 0 from bottom left to top right, only by moving either up or to the right. The input file contains a grid of characters, where ...
user avatar
2 votes
2 answers
770 views

Find subsets of size K in N set

The question is: There is a set An, and it consists of integers from 1 to n. ...
Roy Yoon's user avatar
11 votes
2 answers
5k views

Lovely Lucky LAMBs

I am trying to solve this question from google's foobar. However, my code exceeds the time limit, even though when I tested it I got correct answers. How can I make my code more efficient? Lovely ...
ngmh's user avatar
  • 113
5 votes
5 answers
7k views

Finding large Fibonacci Number in Python

I'm doing Project Euler at 1000-digit Fibonacci number - Problem 25 which says The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. ...
user avatar
2 votes
1 answer
506 views

How many ways we can make the change of the amount using the coins given

Given a set of coins and amount, write an algo­rithm to find out how many ways we can make the change of the amount using the coins given. Exam­ple: Amount = 5 ...
Komal-SkyNET's user avatar
1 vote
0 answers
888 views

Hackerrank > Woman's CodeSprint 2 > stone division, Revisited ( recursive function)

Problem statement You have a pile of n stones that you want to split into multiple piles, as well as a set, S, of ...
Jianmin Chen's user avatar
  • 2,396

15 30 50 per page