Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class IsArrayInWaveFrom {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- String [] arr = input.split(" ");
- Integer [] arryInt = new Integer[arr.length];
- String wave ="";
- for (int i = 0; i < arr.length ; i++) {
- arryInt[i] = Integer.parseInt(arr[i]); } // filling the Int array
- for (int i = 1 ; i < arryInt.length; i+=2) {
- for (int j = 2; j < arryInt.length; j++) {
- if (arryInt[i - 1] > arryInt[i]) {
- if (arryInt[j - 1] < arryInt[j]) {
- wave = "Yes";
- }
- } else {
- wave = "No";
- }
- }
- }
- System.out.println(wave);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment