2009 FRQ 3b
public int getChargeStartTime(int chargeTime)
{
int cheapestStartHour = 0;
for(int startHour = 1; startHour < rateTable.length; startHour++)
if(getChargingCost(startHour, chargeTime) <
getChargingCost(cheapestStartHour, chargeTime))
cheapestStartHour = startHour;
return cheapestStartHour;
}
public boolean isStrictlyIncreasing()
{
for (int i = 0; i < digitList.size()-1; i++)
{
if (digitList.get(i).intValue() >= digitList.get(i+1).intValue())
{
return false;
}
}
return true;
}
public boolean isBalanced(ArrayList<String> delimiters) {
int openDels = 0;
int closeDels = 0;
for (String del : delimiters) {
if (del.equals(openDel)) {
openDels++;
} else {
closeDels++;
}
if (closeDels > openDels) {
return false;
}
}
return openDels == closeDels;
}