« All Events
3 PM – Intro To Competitive Programming – Gamas
April 20 @ 3:00 pm - 4:00 pm
Today We Did
- We reviewed Maximizing Productivity USACO Feb 2024 Bronze problem from https://usaco.org/index.php?page=viewproblem2&cpid=1397. We discussed how to optimize the solution from Big O(N^2) to Big O (N Log N) and passed all the test cases.
- We reviewed the Milk Exchange USACO Feb 2024 Bronze problem from https://usaco.org/index.php?page=viewproblem2&cpid=1396 . We discussed the optimize solution.
Homework
- We want to dig deep into Java sorting mechanism. Look at SortingTutorial.java we did several months ago.
- Create a new class GameSorting.java. Inside this class, create a List<Game>. And add 6 games to it.
- Mario, $60, Not on sale
- Kirby, $55, Not on sale
- Donkey kong, $30, on sale.
- Zelda, $65, Not on sale.
- Hero, $20, on sale.
- Sticky Man, $25, on sale.
- Sort the above list of game according to its price ascending order.
- Sort the above list of game according to its price descending order.
- Use below Game.java class
public class Game {
private String name;
private double price;
private boolean onSale;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public boolean isOnSale() {
return onSale;
}
public void setOnSale(boolean onSale) {
this.onSale = onSale;
}
public Game(String name, double price, boolean onSale) {
this.name = name;
this.price = price;
this.onSale = onSale;
}
}