Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.List;
- import java.util.Scanner;
- import java.util.stream.Collectors;
- public class FirstProblem {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- List<String> text = Arrays.stream(scan.nextLine().split("")).collect(Collectors.toList());
- for (int i = 0; i < text.size() - 1 ; i++) {
- if (text.size() > 1 ) {
- if (text.get(i).equals(text.get(i + 1))) {
- text.remove(i);
- i = -1;
- }
- }
- }
- System.out.println(text.toString().replaceAll("\\[|\\]|\\,\\s+", ""));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement