ashwanilabs
BAN USERUse a bit vector and flip the resp. bit while scanning the list.
- ashwanilabs July 17, 2012Please explain it a little further. If possible give a sample example
- ashwanilabs July 17, 2012Use Strings to represent long data.
- ashwanilabs July 12, 2012public class CircularQueue {
private final int SIZE = 10;
private int[] arr = new int[SIZE];
private int head = -1;
private int tail = 0;
public void enqueue(int n){
if(head == tail){
System.out.println("Queue is Full");
} else {
synchronized (this){
if(head == -1) head = 0;
arr[tail] = n;
tail=(tail+1)%SIZE;
}
}
}
public int dequeue() throws Exception{
if(head == -1){
throw new Exception("Queue is Empty");
} else {
int n;
synchronized (this) {
n = arr[head];
head=(head+1)%SIZE;
if(head == tail){
head = -1;
tail = 0;
}
}
return n;
}
}
}
public class InterleaveString {
public static void printInterleaving(String s1, String s2, String s){
if(!s1.isEmpty())
printInterleaving(s1.substring(1), s2,s+s1.charAt(0));
if(!s2.isEmpty())
printInterleaving(s1, s2.substring(1), s+s2.charAt(0));
if(s1.isEmpty() && s2.isEmpty())
System.out.println(s);
}
public static void main(String[] args) {
String s1 = "AB";
String s2 = "CD";
printInterleaving(s1,s2,"");
}
}
Refer: Subset_sum_problem on wiki
- ashwanilabs January 03, 2012
Reprobinroi335, Android test engineer at ABC TECH SUPPORT
I believe the deepest changes you can make to improve your quality of life. how to break a family curse ...
RepIndianastrologyguru, Data Scientist at ABC TECH SUPPORT
Hey I'm Shelly Renee and I'm working as a system developer. Currently working part time on a project ...
you can always use a constant space. if know the range of numbers here a bit vector can be used.
- ashwanilabs July 17, 2012