SHARE
TWEET

Untitled

a guest Mar 25th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Stack;
  5.  
  6. public class Main {
  7.  
  8.     public static boolean check(int a){
  9.         Stack<Integer> stack = new Stack<>();
  10.  
  11.         while(a != 0){
  12.             stack.add(a%10);
  13.             a = a/10;
  14.         }
  15.         int pref = 0;
  16.         while(!stack.isEmpty()){
  17.             if(stack.peek() < pref){
  18.                 return false;
  19.             }
  20.             pref = stack.pop();
  21.         }
  22.         return true;
  23.     }
  24.     public static boolean checkArray(int[] a){
  25.         for(int i = 0; i < a.length; i++){
  26.             if(!check(a[i])){
  27.                 return false;
  28.             }
  29.         }
  30.         return true;
  31.  
  32.     }
  33.  
  34.     public static int solution(int[][] arr){
  35.         int res = 0;
  36.         for(int i = 0; i < arr.length;i++){
  37.            if(checkArray(arr[i])){
  38.                res++;
  39.            }
  40.         }
  41.         return res;
  42.     }
  43.  
  44.     public static void main(String[] args){
  45.         System.out.println(check(21));
  46.     }
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top