Jyothi
BAN USERpublic class MaxCars {
static int[] startArr = { 1, 2, 3, 5 };
static int[] endArr = { 3, 3, 4, 6 };
//static int[] cars = { 2, 3, 6, 2 };
static int[] cars = { 2, 3, 4, 2 };
public static void main(String[] ar) {
System.out.println("Max Cars : " + getMaxCars(startArr.length));
}
private static int getMaxCars(int n) {
int max = cars[0];
int currentCount = max;
int i = 1, j = 0;
while (i < n && j < n) {
if (startArr[i] < endArr[j]) {
currentCount = currentCount + cars[i];
i++;
if (currentCount > max) {
max = currentCount;
}
} else {
currentCount = currentCount  cars[j];
j++;
}
}
return max;
}
}

Jyothi
January 20, 2016 public class MaxCars {
static int[] startArr = { 1, 2, 3, 5 };
static int[] endArr = { 3, 3, 4, 6 };
//static int[] cars = { 2, 3, 6, 2 };
static int[] cars = { 2, 3, 4, 2 };
public static void main(String[] ar) {
System.out.println("Max Cars : " + getMaxCars(startArr.length));
}
private static int getMaxCars(int n) {
int max = cars[0];
int currentCount = max;
int i = 1, j = 0;
while (i < n && j < n) {
if (startArr[i] < endArr[j]) {
currentCount = currentCount + cars[i];
i++;
if (currentCount > max) {
max = currentCount;
}
} else {
currentCount = currentCount  cars[j];
j++;
}
}
return max;
}
}
public static String generateLowestNumber(StringBuilder str, int num) {
if (num == 0) {
return str.toString();
}
for (int i = 0; i < str.length()1; i++) {
if (getNumValue(str.charAt(i)) >= getNumValue(str.charAt(i + 1))) {
str.deleteCharAt(i);
i;
num;
}
if (num == 0) {
break;
}
}
return str.toString();
}
public static int getNumValue(Character c) {
return Character.getNumericValue(c);
}
 Jyothi October 23, 2017