Day 14: Scope Java stream OptionalInt
来源:互联网 发布:天眼查 知乎 编辑:程序博客网 时间:2024/06/14 11:39
source: https://www.hackerrank.com/challenges/30-scope
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
class Difference {
private int[] elements;
public int maximumDifference;
Difference(int[] elements) {
this.elements = elements;
}
public void computeDifference() {
this.maximumDifference = Arrays.stream(this.elements).max().getAsInt() - Arrays.stream(this.elements).min().getAsInt();
}
} // End of Difference class
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
sc.close();
Difference difference = new Difference(a);
difference.computeDifference();
System.out.print(difference.maximumDifference);
}
}
0 0
- Day 14: Scope Java stream OptionalInt
- JAVA DAY DAY UP
- Java Stream
- Java自学日记 day 14
- JAVA SE — Day 14
- Java Stream(8)(Stream完结)
- java 的 Stream.
- JAVA :Stream to String
- JAVA Stream 简单操作
- Java IO Stream 总结
- Java IO Stream 总结
- Java Stream 散记
- Java IO Stream 总结
- java IO Stream 使用
- JAVA的一些Stream
- java string stream 转换
- Java IO Stream 总结
- Java Stream Closed异常
- 第三周项目4-顺序表应用(2)
- JAVA反射
- Gym 100507J Scarily interesting!
- C++:sprintf()的用法
- Spring学习第六天:Bean之间的关系
- Day 14: Scope Java stream OptionalInt
- IDEA集成golang插件
- NOIP提高组需要的一些模板【不定时更新】
- 判断某年是否为闰年
- 2016 ACM/ICPC Asia Regional Qingdao Online 1002Cure
- 读取jpeg图像数据
- JAVA的 IO流 详解
- android Toast工具类,可自定义位置和取消显示
- 雷达安装(贪心)