public class Main {
public static int maxProfit(int[] prices) {
// TODO: find the maximum profit from a single buy/sell
return 0;
}
public static void main(String[] args) {
System.out.println(maxProfit(new int[]{7, 1, 5, 3, 6, 4})); // 5
System.out.println(maxProfit(new int[]{7, 6, 4, 3, 1})); // 0
}
}
Click Run to execute, or Submit to grade (all languages).