You are given N blocks of height 1…N. In how many ways can you arrange these blocks in a row such that when viewed from left you see only L blocks (rest are hidden by taller blocks) and when seen fro
I was wondering how to solve such a problem using DP. Given n balls and开发者_JAVA技巧 m bins, each bin having max. capacity c1, c2,...cm. What is the total number of ways of distributing these n bal
This question already has answers here: Closed 11 years ago. Possible Duplicate: is there any best way to generate all possible three letters keywords
I am looking for the scala way to give all permutations without repetitions. I know there are some postings on this site already but they seem to have a slightly different problem.
To solve my problem it is natural to use base 3 numbers. I have several tables indexed by base 3 numbers, and at some point I need to go through all the indexes that differ in k digits from a given N-
Given an array [\'a\', \'b\', \'c\', \'d\', \'e\',开发者_开发问答 \'f\'], how would I get a list of all subsets containing two, three, and four elements?
This question already has answers here: How to get the Cartesian product of multiple lists (18 answers)
How can I obtain all combinations for a list where combination size need only be static eg. if the list has 4 elements then it will only need permutations of length 4 not 3, 2 and 1. I\'m guessing thi
I want to shuffle a list of unique items, but not do an entirely random shuffle. I need to be sure that no element in the shuffled list is at the same position as in the original list. Thus, if the or
How can I obtain every possible combination for a dynamic sized set? can it be done without recursion or methods? I\'ve been trying to figure ou开发者_JAVA技巧t how to do it with just loops for the pa