Answers for "string challenge coderbyte print distinct characters in string that is non repetitive"

0

string challenge coderbyte print distinct characters in string that is non repetitive

class DuplicateLetters {

  private static final String DUPSFOUND = "duplicates found";
  private static final String NODUPS = "all unique";

  private static boolean sameLetter(char s1, char s2) {
    return (Character.toUpperCase(s1) == Character.toUpperCase(s2));
  }

  public static void main(String args[]) {

    String s = args[0];
    Boolean found=false;

    System.out.println(s);

mainloop:
    for(int i=1; i<s.length(); i++) {
      for (int j=0; j<i; j++) {
        if (sameLetter(s.charAt(i), s.charAt(j))) {
          found = true;
          break mainloop;
        }
      }
    }
    System.out.println(found ? DUPSFOUND : NODUPS);
  }
}
Posted by: Guest on April-28-2022

Code answers related to "string challenge coderbyte print distinct characters in string that is non repetitive"

Browse Popular Code Answers by Language