I have a network of stations in a subway system. The number of stations, the number of tickets I can travel between stations with, and which stations are connected to each other are given in a text ...

N students are in line. And we can consider there arrangement best when maximum number of students are satisfied. A student is satisfied if he is the right neighbor of his best friend. Each student ...

I'm trying to get Maximum numbers of elements that their sum is less than or equal some variable but i don't know how i can memoize it and call the funcition from main()so that it passes the allowed ...

I need to create a VF page(very simple). And i have a requirement where i need to build custom filter criteria in VF page on specific object(let's say Account).That's again not so difficult, As i can ...

If you are given one set of items with values and weight: [(w1,v2),(w2,v2),...(wn,vn)], and two knapsacks Knap1 and Knap2 of equal capacity C, the goal is to determine what are the optimal subsets of ...

So let's say I have an acyclic, directed graph G with nodes a0, a1, a2, b0, b1, b2, c0, c1, c2 and I know both the outgoing distance for each node to any of it's neighbors. What algorithm can I use to ...

As the question states,we are given a positive integer M and a non-negative integer S. We have to find the smallest and the largest of the numbers that have length M and sum of digits S.
Constraints:
...

I have an understanding of the basic 0-1 knapsack problem and its solution. I am trying to reason through a variant of the 0-1 problem where instead of being able to select any combination of items ...

In 0/1 knapsack problem, how do I select items, if two items have same value. The value with the lesser weight should be selected , how do I check that condition? I have the following function using ...

We can simply modify the travelling salesman problem to get whether a Hamilton walk exists or not in O(2^N * N^2)Time Complexity.
But I read it at codeforces that it is possible to solve this problem ...

This is the problem
Given an array of ints, is it possible to choose a group of some of the ints, such that the group sums to the given target with these additional constraints: all multiples of 5 in ...

Here is the challenge: The input is an array X of N integers (N is in range 0 to 10'000, X[i] is in range -100 to 100). The goal is to find a sequence D consisting of N integers from the set {-1; 1} ...

I'm new to Dynamic Programming and from my understanding Dynamic Programming is where you use the results that you calculated to check if your function is correct. I was asked during an interview to ...

I am solving a this spoj problem. Its been 3 days and I am unable to debug. My solution perfectly gives optimal value but it is not properly determining the items that are put in the knapsack to get ...

i am php developer. developed web portal with own framework and using dynamic meta tags for description and keywords. for example different keywords and different description based on language. but ...

I have a perl script that I use to extract data from a raw data/log file. I need help on making the script dynamic. First, let me show you the part of the perl script and raw data file.
Perl script:
...

Write a program that takes as input the width, W and height H of the grid and outputs the number of different ways to tile a W-by-H grid with (2x1) dominoes
I know how to solve the problem with 3 x N ...

Link to problem: https://projecteuler.net/problem=14
So I've solved this problem using a fairly 'trivial' implementation of memoization in R. Basically, I just count up from 1:1,000,000 and count the ...

Is is possible to find the largest sum contiguous sub array using recursion such that the function would directly return the output.
Below is my solution where I store the max subarray ending at each ...

The Problem statement:
Assurance Company of Moving (ACM) is a company of moving things for people. Recently, some schools want to move their computers to another place. So they ask ACM to help them. ...