SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.*;
  2.  
  3. public class Puppy {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String[] arr = scanner.nextLine().split(",");
  10.  
  11.         int sizeArr = arr.length;
  12.  
  13.         List<String> arrList = Arrays.asList(arr);
  14.  
  15.         List<String> result1 = new ArrayList<>();
  16.         List<String> result2 = new ArrayList<>();
  17.  
  18.  
  19.         int num = Integer.parseInt(scanner.nextLine());
  20.  
  21.         for (int i = 0; i < num; i++) {
  22.  
  23.             result1.add(arrList.get(i));
  24.         }
  25.  
  26.         for (int i = 1; i <= num; i++) {
  27.  
  28.             result2.add(arrList.get(sizeArr - i));
  29.         }
  30.  
  31.         Collections.reverse(result2);
  32.  
  33.         if (result1.equals(result2)) {
  34.  
  35.             System.out.print("true ");
  36.             System.out.print(String.join(",", result1));
  37.         }
  38.  
  39.         for (int i = 0; i < result1.size(); i++) {
  40.  
  41.             if (!(result1.get(i).equals(result2.get(i)))) {
  42.  
  43.                 System.out.printf("false %s,%s", result1.get(i),result2.get(i));
  44.                 return;
  45.             }
  46.         }
  47.     }
  48. }
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