| package com.zy.acs.common.circulrgv; | 
|   | 
| import java.util.ArrayList; | 
| import java.util.List; | 
|   | 
|   | 
| /** | 
|  * Created by vincent on 2023/9/21 | 
|  */ | 
| public class Main { | 
|   | 
|     public static void main(String[] args) { | 
|         String input = "AAAAXYXYAAXZAAXYAAAAXYA"; // 你的输入字符串 | 
|         List<Character> myList = new ArrayList<>(); | 
|         for (char c : input.toCharArray()) { | 
|             myList.add(c); | 
|         } | 
|         for (Character character : myList) { | 
|             System.out.print(character); | 
|         }   System.out.println(); | 
|   | 
|   | 
|         // 重新排列列表 | 
|         List<Integer> removeIdx = new ArrayList<>(); | 
|         int lastYIdx = -1; | 
|         for (int i = 0; i<myList.size(); i++) { | 
|             char curr = myList.get(i); | 
|             if (curr == 'X') { | 
|                 if (lastYIdx == -1) { | 
|                     continue; | 
|                 } else { | 
|                     myList.add(lastYIdx + 1, curr); | 
|                     i += 1; | 
|                     removeIdx.add(i); | 
|                 } | 
|             } | 
|             if (curr == 'Y' || curr == 'Z') { | 
|                 lastYIdx = i; | 
|             } | 
|         } | 
|   | 
|         List<Character> exlist = new ArrayList<>(); | 
|         for (int i = 0; i < myList.size(); i++) { | 
|             char c = myList.get(i); | 
|             if (!removeIdx.contains(i)) { | 
|                 exlist.add(c); | 
|             } | 
|         } | 
|   | 
|         System.out.println(removeIdx); | 
|         for (Character character : exlist) { | 
|             System.out.print(character); | 
|         }   System.out.println(); | 
|   | 
|     } | 
|   | 
| } |