You are viewing a single comment's thread. Return to all comments →
Mine in Java
import java.util.Scanner; public class RemoveDuplicateLetters { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String str = scanner.next(); for (int i = 1; i < str.length(); i++) { if (str.charAt(i) == str.charAt(i-1)) { str = str.substring(0, i-1) + str.substring(i+1); i = 0; } } if (str.length() == 0) { System.out.println("Empty String"); } else { System.out.println (str); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Super Reduced String
You are viewing a single comment's thread. Return to all comments →
Mine in Java