Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.ArrayList;
- import java.util.Stack;
- public class Main {
- public static boolean check(int a){
- Stack<Integer> stack = new Stack<>();
- while(a != 0){
- stack.add(a%10);
- a = a/10;
- }
- int pref = 0;
- while(!stack.isEmpty()){
- if(stack.peek() < pref){
- return false;
- }
- pref = stack.pop();
- }
- return true;
- }
- public static boolean checkArray(int[] a){
- for(int i = 0; i < a.length; i++){
- if(!check(a[i])){
- return false;
- }
- }
- return true;
- }
- public static int solution(int[][] arr){
- int res = 0;
- for(int i = 0; i < arr.length;i++){
- if(checkArray(arr[i])){
- res++;
- }
- }
- return res;
- }
- public static void main(String[] args){
- System.out.println(check(21));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement