Java Code
Thanks Arun Tomar for providing the code.
Below is the solution with Java Collection perspective. Please see to it if it fine according to the best case solutions.
public class Ritamtest { private static String name = "social.ritambhara.in"; public static void main(String[] arun) { removeDuplicate(name); } private static void removeDuplicate(String str) { Set<Character> set = new TreeSet<Character>(); for (int i = 0; i < str.length(); i++) { if (!(set.contains(str.charAt(i)))) { set.add(str.charAt(i)); } } for (char cha : set) { System.out.println("Set values : " + cha); } } }
Please let me know your feedback / suggestions / comments.
2 Comments
where is n in array?
n is the size of string.