题解 | #比特币最佳买卖时机#
比特币最佳买卖时机
https://www.nowcoder.com/practice/08f70daa78bf45fea64d72523a3641f3
import java.util.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String[] s = in.nextLine().split(" "); int[] res = new int[s.length]; for(int i = 0; i < s.length; i++){ res[i] = Integer.parseInt(s[i]); } int minn = Integer.MAX_VALUE; int maxx = 0; for(int i = 0; i < res.length; i++){ maxx = Math.max(maxx, res[i] - minn); minn = Math.min(minn, res[i]); } System.out.println(maxx); } }