I am working on a project involving "Dynamic Programming" and am struck on this trivial thing, please help.
Suppose I take 4 as an input, I want to display something like: 0000 to 1111
But, if I input 5, I want to display like: 00000 to 11111 and so on.
Thanks in advance,
EDIT: Please don't post asking me for the code. This is not a homework problem and I don't need any code, just tell me the logic for it and I would be happy.
EDIT2: WTH is happening with Stackoverflow, did I ask any of you to write code for me? I want the person who downvoted to upvote it. What is a point of this forum if I can't for help?
Share the logic with me. We can discuss and I do not require the code for this.
EDIT3: Here I am posting the code which I tried. I hope this "SATISFIES" all the people who were thinking I have not tried anything.
import java.util.ArrayList;
public class RegularInvestigator {
public ArrayList createCombinations(ArrayList listOfFlightNumbers) {
ArrayList<String> result = new ArrayList<String>();
for(int i = 1; i < listOfFlightNumbers.size(); i++) {
String binaryEqvivalent = Integer.toBinaryString(i);System.out.println(binaryEqvivalent);
String element = "";
for(int j = 0; j < binaryEqvivalent.length(); j++)
if(binaryEqvivalent.charAt(j) == '1')
element += listOfFlightNumbers + " ";
result.add(element.substring(0, element.length() - 1));
}
return result;
}
private String getContent(ArrayList<String> flight) {
String temp = "";
for(int i = 0; i < flight.size() - 1; i++) temp += flight.get(i) + " ";
temp += flight.get(flight.size() - 1);
return temp;
}
private ArrayList removeElementAtIndex(ArrayList flight, int position) {
ArrayList<String> res = new ArrayList<String>();
for(int i = 0; i < flight.size(); i++) {
if(i != position) res.add(flight.get(i));
}
return res;
} }
EDIT4: Thank you phoxis, PengOne, Jerry Coffin and oliholz for your valuable answers :)